package Form;

import java.awt.Container;
import java.awt.Desktop;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JTabbedPane;
import java.awt.BorderLayout;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.border.TitledBorder;
import java.awt.Color;

import javax.swing.plaf.basic.BasicBorders.RadioButtonBorder;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;
import javax.swing.border.LineBorder;
import javax.swing.JTextField;
import javax.swing.JLabel;
import javax.swing.JButton;
import java.awt.Font;
import java.util.Locale;

import javax.swing.ImageIcon;
import javax.swing.JComboBox;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JOptionPane;
import javax.swing.JTextArea;
import javax.swing.border.EtchedBorder;
import javax.swing.ComboBoxModel;
import javax.swing.JDialog;
import javax.swing.JSeparator;
import javax.swing.JPasswordField;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.ButtonGroup;
import javax.swing.SwingConstants;

import Support.International;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import Class.Attendance_Management;
import Class.ConnectDatabase;
import Class.Connection_Mail;
import Class.Courier;
import Class.Courier_Management;
import Class.CreateAccount;
import Class.Employee;
import Class.MD5;
import Class.Procedure;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.io.File;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.List;
import java.util.Locale;
import java.util.Vector;

import javax.swing.event.AncestorListener;
import javax.swing.event.AncestorEvent;
import javax.swing.JScrollPane;

import Support.*;
import javax.swing.ListSelectionModel;
import javax.swing.JScrollPane;
import javax.swing.JRadioButton;

import org.jdesktop.swingx.JXDatePicker;
import javax.swing.JList;
import javax.swing.AbstractListModel;

public class Main {
	//security
	private DefaultTableModel modelTable;
	private DefaultTableModel model2 ;
	private JTextField tfInfoLoginName;
	private JTextField tfInfoName;
	private JTextField tfInfoPhone;
	private JTextField tfInfoEmail;
	private JTextField tfFindLoginName;
	private JTextField tfInfoDateCreated;
	private JTextField tfAddLoginName;
	private JTextField tfAddName;
	private JTextField tfAddPhone;
	private JTextField tfAddEmail;
	private JTextField tfAddYourAnswer;
	private JTextField tfMyInfoLoginName;
	private JTextField tfMyInfoDateCreated;
	private JTextField tfMyInfoName;
	private JTextField tfMyInfoPhone;
	private JTextField tfMyInfoNameEmail;
	private JTextArea taInfoAddress ;
	private JTextArea taMyInfoAddress;
	private JComboBox cbInfoFunction;
	private JComboBox cbMyInfoFunction;
	private JComboBox cbMyInfoWorkingStatus;
	private JComboBox cbInfoEmail;
	private JComboBox cbFindFunction;
	private JPasswordField tfMyInfoCurrentPassword;
	private JPasswordField tfMyInfoNewPassword;
	private JPasswordField tfMyInfoConfirmNewPassword;
	private final ButtonGroup buttonGroup = new ButtonGroup();
	private JRadioButtonMenuItem radioEnglish;
	private JRadioButtonMenuItem radioVietnamese;
	private File addAvatar;
	private File myAvatar;
	private File infoAvatar;
	private JTable table;
	private JPanel panelMailNotification;
	private JTextArea taAddAddress;
	private JTable tbList;
	private JPanel pnAttendance;
	private JTextField tfSearchAttendanceLoginname;
	private JTable tableAttendance;
	public static JTabbedPane tabbedPaneCouriers;
	private JTextField tfFindCNum;
	private JTextField tfFindLName;
	private JTable tbCouShow;
	private JTextField tfCourierInfo_CourierNumber;
	private JTextField tfCouSName;
	private JLabel lblNameOfSender_1;
	private JLabel lblNameOfReceiver;
	private JTextField tfFindRName;
	private JTextField tfFindSName;
	private JTextField tfCouLoginName;
	private JTextField tfCou_Amount;
	private JTextField tfCouSPhone;
	private JTextField tfCouRName;
	private JTextArea taCouRAddress;
	private JTextField tfCouRPhone;
	private JTextArea taCouSAddress;
	private JLabel lbAddCurrentTime;
	private JScrollPane scrollPane_4;
	private JTextField tfCalDistance;
	private JTextField tfCal_location;
	private JTable table_2;
	private JScrollPane scrollPane_6;
	private JScrollPane scrollPane_7;
	private JTable tbCalTrade;
	public static JButton btnCalDefault;
	public static JButton btnCalEdit;
	private JTextField tfCouWeight;
	private JComboBox<String> cbCouStatus;
	private JScrollPane scrollPane_8;
	private JTable tableNotSent;
	private JComboBox cbSearchAttendanceFunction;
	private JLabel lblInfoDateAttendance ;
	public static JComboBox cbAttSearchAbsence;
	private JTextField tfSearchNotSentLogin;
	private DefaultTableModel model3;
	private JComboBox<String> cbCouSProvince;
	private JComboBox<String> cbCouRProvince;
	private final ButtonGroup buttonGroup_1 = new ButtonGroup();
	private JXDatePicker tfcouDatetime;
	private JXDatePicker tfFindDate ;
	private JComboBox cbCal_S_province;
	private JComboBox cbCal_R_province;
	private JButton btnCourierInfo_OK;
	//public labels for multi-language
	public static JFrame frmCourierManagementSystem;
	public static JPanel pnCouSender;
	public static JPanel pnCouReceiver;
	public static JPanel pnEmployees;
	public static JPanel pnCouriers;
	public static JPanel pnMyInfo;
	public static JPanel pnListEmployees;
	public static JPanel pnFindEmployee;
	public static JPanel pnListTableEmployee;
	public static JPanel pnChangeMyPassword;
	public static JPanel pnInfoEmployee;
	public static JPanel pnFindCourier;
	public static JPanel pnCourierService;
	public static JPanel pnInfoCourier;
	public static JPanel pnAddNewLocation;
	public static JPanel pnListRoutes;
	public static JPanel pnAddNewRoute;
	public static JPanel pnCharges;
	public static JPanel pnMyInfoAvatar;
	public static JPanel pnAddAvatar;
	public static JPanel pnInfoAvatar;
	public static JPanel pnListLocations;
	public static JPanel panelConnection;
	public static JPanel pnConnList;
	public static JPanel pnAttSearch;
	public static JPanel pnConnSearch ;
	public static JPanel pnAttList;
	public static JPanel pnCouCalculator;
	public static JPanel pnCouManagement;
	public static JLabel lbMyInfoID;
	public static JLabel lbInfoIndexID;
	public static JLabel lbAddID;
	public static JLabel lblNow;
	public static JLabel lblFindLoginName;
	public static JLabel lblFindFunction;
	public static JLabel lblFindWorkingStatus;
	public static JLabel lbCoFindCourierName;
	public static JLabel lbCoFindLoginName;
	public static JLabel lbInfoLoginName;
	public static JLabel lbInfoDateCreated;
	public static JLabel lbInfoName;
	public static JLabel lbInfoAddress;
	public static JLabel lbInfoPhone;
	public static JLabel lbInfoEmail;
	public static JLabel lbInfoFunction;
	public static JLabel lbInfoWorkingStatus;
	public static JLabel lblInfoLoginName;
	public static JLabel lblInfoDateCreated;
	public static JLabel lblInfoName;
	public static JLabel lblInfoAddress;
	public static JLabel lblInfoPhone;
	public static JLabel lblInfoEmail;
	public static JLabel lblInfoFunction;
	public static JLabel lblInfoWorkingStatus;
	public static JLabel lbAddLoginName;
	public static JLabel lbAddName;
	public static JLabel lbAddAddress;
	public static JLabel lbAddPhone;
	public static JLabel lbAddFunction;
	public static JLabel lbAddWorkingStatus;
	public static JLabel lbAddSecurityQuestion;
	public static JLabel lbAddYourAnswer;
	public static JLabel lbAddDate;
	public static JLabel lbWarningChangePassword;
	public static JLabel lbMyInfoLoginName;
	public static JLabel lbMyInfoName;
	public static JLabel lbMyInfoAddress;
	public static JLabel lbMyInfoDateCreated;
	public static JLabel lbMyInfoPhone;
	public static JLabel lbMyInfoEmail;
	public static JLabel lbMyInfoFunction;
	public static JLabel lbMyInfoWorkingStatus;
	public static JLabel lbMyInfoCurrentPassword;
	public static JLabel lbMyInfoNewPassword;
	public static JLabel lbMyInfoConfirmNewPassword;
	public static JLabel lbCoFindNameSender;
	public static JLabel lbCoFindNameReceiver;
	public static JLabel lbReceiverPhone;
	public static JLabel lbCoInfoDateCreated;
	public static JLabel lbCoInfoStatus;
	public static JLabel lbCoInfoAmount;
	public static JLabel lbReceiverName;
	public static JLabel lbReceiverAddress;
	public static JLabel lbReceiverLocation;
	public static JLabel lbCoInfoCourierName;
	public static JLabel lbCoInfoWeight;
	public static JLabel lbCoInfoLoginName;
	public static JLabel lbSenderName;
	public static JLabel lbSenderAddress;
	public static JLabel lbSenderLocation;
	public static JLabel lbSenderPhone;
	public static JLabel lbLocation;
	public static JLabel lbFrom;
	public static JLabel lbTo;
	public static JLabel lbDistance;
	public static JLabel lblDate_2;
	public static JLabel lbConnLogin;
	public static JLabel lbConnDate;
	public static JLabel lblMailNotification;
	public static JLabel lblAttSearchLoginname;
	public static JLabel lblAttSearchFunction;
	public static JLabel lblAttSearchAbsence;
	public static JLabel lblAttSearchDate;
	public static JLabel lblDate;
	public static JButton btnAttDefault;
	public static JButton btnAttSave;
	public static JButton btnAttSearch;
	public static JButton btnAttShowAll;
	public static JButton btnAddNewLocation;
	public static JButton btnAddNewRoute;
	public static JButton btnShowAllCourier;
	public static JButton btnfindCourier;
	public static JButton btnMyInfoDefault;
	public static JButton btnMyInfoEdit;
	public static JButton btnMyInfoChange;
	public static JButton btnAddEmployee;
	public static JButton btnDeleteEmployee;
	public static JButton btnEditEmployee;
	public static JButton btnFindEmployee;
	public static JButton btnMyInfoAvatar;
	public static JButton btnInfoAvatar;
	public static JButton btnAddAvatar;
	public static JButton btnShowAllEmployees;
	public static JButton btnDeleteConn;
	public static JButton btnDefaultConn;
	public static JButton btnEmployeeDetail;
	public static JButton btnSendMail;
	public static JButton btnSelectAllConn;
	public static JButton btnConnSearch;
	public static JButton btnConnShowAll;
	public static JButton btnAttDetail;
	public static JMenu mnSystem;
	public static JMenu mnLanguage;
	public static JMenu mnHelp;
	public static JMenuItem itemAbout;
	public static JMenuItem itemLogout;
	public static JMenuItem itemExit;
	public static JMenuItem itemHelp;
	public static JTabbedPane tabbedPane;
	public static JTabbedPane tabbedPaneEmployees;
	public static JComboBox cbFindWorkingStatus;
	public static JComboBox cbAddWorkingStatus;
	public static JComboBox cbInfoWorkingStatus;
	public static JComboBox cbAddFunction;
	public static JComboBox cbAddSecurityQuestion;
	public static JComboBox cbMyInfoEmail;
	public static JRadioButton rdbtnCouUpdate;
	public static JRadioButton rdbtnCouDelete;
	public static JRadioButton rdbtnCouNew;
	public static JXDatePicker tfSearchNotSentDate;		
	public static JXDatePicker tfSearchAttendanceDate;
	
	private String timeStamp;
	private static Employee emp = new Employee();
	private Vector<String> listLocs = new Vector<String>();
	private JList listLocations;
	private Courier cr= new Courier();
	private int tempCheckCouRadio;
	
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
			}
		});
	}


	/**
	 * @wbp.parser.entryPoint
	 */
	public Main(int decentralization,Employee emp) {
		this.emp = emp;
		timeStamp = new SimpleDateFormat("dd-MM-yyyy").format(Calendar.getInstance().getTime());
		listLocs = Procedure.showLocations();
		initialize();
	
		java.sql.Date now =  new java.sql.Date(new java.util.Date().getTime());
		try
		{
			SimpleDateFormat sdf = new SimpleDateFormat("dd-MM-yyyy");
	    	Date dateNow = sdf.parse(now.toString());
	    	Date dateData = sdf.parse(CreateAccount.Date().toString());
	    	lblInfoDateAttendance.setText(timeStamp);
	    	Procedure.List_Emp(modelTable, tbList, 1, "",emp.getLoginName(), 0, 0);
	    	if(dateNow.compareTo(dateData) != 0)
			{
				Attendance_Management.setAttendance();
			}
		} catch(Exception ex) {}
		Attendance_Management.getAttendance(tableAttendance,emp.getLoginName(),new Date());
		
		btnAttDetail = new JButton("Detail");
		btnAttDetail.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				tabbedPaneEmployees.setSelectedIndex(0);
			}
		});
		btnAttDetail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAttDetail.setBounds(432, 469, 84, 27);
		pnAttendance.add(btnAttDetail);
		if (tbList.getRowCount() != 0)
		{
			tbList.changeSelection(0, 0, false, false);
			Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, tbList.getValueAt(tbList.getSelectedRow(), 1).toString(),btnInfoAvatar );
		}
		
		this.emp.setMyInfo(lbMyInfoID, tfMyInfoLoginName, tfMyInfoName, taMyInfoAddress, tfMyInfoDateCreated, tfMyInfoPhone, tfMyInfoNameEmail, cbMyInfoEmail, cbMyInfoFunction, cbMyInfoWorkingStatus,btnMyInfoAvatar);
		String tempAvatar = btnMyInfoAvatar.getIcon().toString().substring(btnMyInfoAvatar.getIcon().toString().lastIndexOf('/')+1,btnMyInfoAvatar.getIcon().toString().length());
		if(tempAvatar.equals("anonymous.png"))
			myAvatar = null;
		else myAvatar = new File("emps\\"+tempAvatar);
		if(Login.flgLanguage == 0)
		{
			International.locale = new Locale("en","UK");
			International.setLanguageMain(International.locale);
			radioEnglish.setSelected(true);
	
		}
		else 
		{
			International.locale = new Locale("vi","VN");
			International.setLanguageMain(International.locale);
			radioVietnamese.setSelected(true);
		}
		Connection_Mail.List_notSent(model3, tableNotSent,0,tfSearchNotSentLogin,tfSearchNotSentDate);
		
		this.frmCourierManagementSystem.setVisible(true);
		if(decentralization == 1)
		{
			//tabbedPane.removeTabAt(1);
			pnCourierService.setVisible(false);
			btnCourierInfo_OK.setVisible(false);
		}else
		if(decentralization == 2)
		{
			check(5);
			check(6);
			rdbtnCouUpdate.setSelected(false);
			rdbtnCouNew.setEnabled(false);
			rdbtnCouDelete.setEnabled(false);
			rdbtnCouUpdate.setEnabled(false);
		//	tabbedPane_1.removeTabAt(1);
			tabbedPaneEmployees.removeTabAt(1);
			tabbedPaneEmployees.removeTabAt(2);
			tabbedPaneEmployees.removeTabAt(1);
			pnCourierService.setVisible(false);
			btnCourierInfo_OK.setVisible(false);
		}else
		if(decentralization == 3)
		{
			rdbtnCouNew.setSelected(true);
			rdbtnCouDelete.setEnabled(false);
			rdbtnCouUpdate.setEnabled(false);
			tabbedPane.removeTabAt(0);
		}else
		if(decentralization == 4)
		{
			tabbedPane.removeTabAt(0);
			tabbedPaneCouriers.removeTabAt(1);
			check(1);
		}
		
		if(tbCouShow.getRowCount() == 0)
		{
			if(decentralization == 2)
			{
				check(5);
				tfCouSName.setText("");
				tfCouSPhone.setText("");
				taCouSAddress.setText("");
				tfCouRName.setText("");
				tfCouRPhone.setText("");
				taCouRAddress.setText("");
				tfCou_Amount.setText("");
				tfCouWeight.setText("");
				cbCouSProvince.setEditable(true);
				cbCouRProvince.setEditable(true);
				cbCouStatus.setEditable(true);
				cbCouStatus.setEnabled(false);
				cbCouSProvince.setEnabled(false);
				cbCouRProvince.setEnabled(false);
				tfCourierInfo_CourierNumber.setText("");
				tfCouLoginName.setText("");
				tfcouDatetime.setDate(null);
				tfcouDatetime.setFormats(new SimpleDateFormat("dd-MM-yyyy"));
			}
			else 
			{
				check(4);
				rdbtnCouNew.setSelected(true);
				rdbtnCouUpdate.setEnabled(false);
				rdbtnCouDelete.setEnabled(false);
			}
		} else
		{
			tbCouShow.changeSelection(0, 0, false, false);
			assign(Courier_Management.Info_Courier((String)tbCouShow.getValueAt(tbCouShow.getSelectedRow(),0)));
			rdbtnCouUpdate.setSelected(true);
		}
		
		tempCheckCouRadio = 0;
		if(rdbtnCouUpdate.isSelected())
			tempCheckCouRadio = 1;
		if(rdbtnCouNew.isSelected())
			tempCheckCouRadio = 2;
		if(rdbtnCouDelete.isSelected())
			tempCheckCouRadio = 3;
	}
	//code for courier
	public void check(int _check)
	{
		//check for update as dispatching department
		if(_check==1){
			rdbtnCouUpdate.setSelected(true);
			rdbtnCouUpdate.setEnabled(true);
			rdbtnCouNew.setEnabled(false);
			rdbtnCouDelete.setEnabled(false);
			tfCouSName.setEditable(false);
			tfCouSPhone.setEditable(false);
			taCouSAddress.setEditable(false);
			tfCouRName.setEditable(false);
			tfCouRPhone.setEditable(false);
			taCouRAddress.setEditable(false);
			tfCou_Amount.setEditable(false);
			cbCouSProvince.setEnabled(true);
			cbCouRProvince.setEnabled(true);
			cbCouStatus.setEnabled(true);
			cbCouSProvince.setEditable(false);
			cbCouRProvince.setEditable(false);
			cbCouStatus.setEditable(false);
			tfCouWeight.setEditable(false);
			tfcouDatetime.setDate(null);
			tfCouLoginName.setText("");
			tfCourierInfo_CourierNumber.setText("");
		}
		//check for delete
		else if(_check==2){
			tfCouSName.setEditable(false);
			tfCouSPhone.setEditable(false);
			taCouSAddress.setEditable(false);
			tfCouRName.setEditable(false);
			tfCouRPhone.setEditable(false);
			taCouRAddress.setEditable(false);
			cbCouSProvince.setEnabled(false);
			cbCouRProvince.setEnabled(false);
			cbCouStatus.setEnabled(false);
			tfCouWeight.setEditable(false);
			cbCouStatus.setEnabled(false);
		}
		//check for adding a new courier and updating as working department
		else if(_check==3)
		{
			rdbtnCouUpdate.setEnabled(true);
			rdbtnCouNew.setEnabled(true);
			rdbtnCouDelete.setEnabled(true);
			tfCouSName.setEditable(true);
			tfCouSPhone.setEditable(true);
			taCouSAddress.setEditable(true);
			tfCouRName.setEditable(true);
			tfCouRPhone.setEditable(true);
			taCouRAddress.setEditable(true);
			cbCouSProvince.setEnabled(true);
			cbCouRProvince.setEnabled(true);
			cbCouStatus.setEnabled(true);
			cbCouStatus.setEditable(false);
			tfCouWeight.setEditable(true);
			tfCouWeight.setText("0");
		}
		//reset
		else if(_check==4)
		{
			tfCouSName.setText("");
			tfCouSPhone.setText("");
			taCouSAddress.setText("");
			tfCouRName.setText("");
			tfCouRPhone.setText("");
			taCouRAddress.setText("");
			tfCou_Amount.setText("0");
			tfCouWeight.setText("");
			cbCouSProvince.setEditable(false);
			cbCouRProvince.setEditable(false);
			cbCouStatus.setEditable(false);
			tfCourierInfo_CourierNumber.setText(Courier_Management.CourierName());
			tfCouLoginName.setText(emp.getLoginName());
			tfcouDatetime.setDate(Calendar.getInstance().getTime());
			tfcouDatetime.setFormats(new SimpleDateFormat("dd-MM-yyyy"));
		}
		//as enquiry department
		else if(_check==5)
		{
			rdbtnCouNew.setEnabled(false);
			rdbtnCouDelete.setEnabled(false);
			rdbtnCouUpdate.setEnabled(false);
			tfCouSName.setEditable(false);
			tfCouSPhone.setEditable(false);
			taCouSAddress.setEditable(false);
			tfCouRName.setEditable(false);
			tfCouRPhone.setEditable(false);
			taCouRAddress.setEditable(false);
			cbCouSProvince.setEnabled(false);
			cbCouRProvince.setEnabled(false);
			cbCouStatus.setEnabled(false);
			tfCouWeight.setEditable(false);
			cbCouStatus.setEnabled(false);
		}
		else if(_check==6)
		{
			tfInfoEmail.setEditable(false);
			tfInfoName.setEditable(false);
			tfInfoPhone.setEditable(false);
			cbInfoEmail.setEnabled(false);
			cbInfoFunction.setEnabled(false);
			cbInfoWorkingStatus.setEnabled(false);
			taInfoAddress.setEditable(false);
		}
	}
	
	//=======================
	//==check for input-=====
	public int check_input(){
		if(tfCouRName.getText().equals("") || tfCouRPhone.getText().equals("") || taCouRAddress.getText().equals("") || tfCouSName.getText().equals("") || tfCouSPhone.getText().equals("") || taCouSAddress.getText().equals("")) 
			return 0;
		if(tfCouRPhone.getText().matches("[0-9]") && tfCouSPhone.getText().matches("[0-9]")) return 1;
		return 1;
	}
	//=======================
	public void check_number(JTable tb, int row, int col){
		row = tb.getSelectedRow();
		col = tb.getSelectedColumn();
		if(tb.getValueAt(row, col).toString().matches(("(?=[^A-Za-z]+$+-).*[0-9].*"))){
			JOptionPane.showMessageDialog(null, "distance must contain numbers only!");
		}
	}
	//=======================
	//assign values
	public void assign(Courier cour)
	{
			tfCourierInfo_CourierNumber.setText(cour.getCourier_name());
			tfCouLoginName.setText(cour.getLogin_name());
			cbCouStatus.setSelectedIndex(cour.getStatus());
			tfCouSName.setText(cour.getS_name());
			tfCouSPhone.setText(String.valueOf((int)cour.getS_phone()));
			taCouSAddress.setText(cour.getS_address());
			tfCouRName.setText(cour.getR_name());
			tfCouRPhone.setText(String.valueOf((int)cour.getR_phone()));
			taCouRAddress.setText(cour.getR_address());
			tfCou_Amount.setText(String.valueOf(cour.getAmount()));
			tfCouWeight.setText(String.valueOf(cour.getWeight()));
			cbCouSProvince.setSelectedIndex(cour.getS_province());
			cbCouRProvince.setSelectedIndex(cour.getR_province());
			tfcouDatetime.setDate(cour.getDate());
			
	}
	//=======================
	//==========================
	//---------------------------
	private void initialize() {
		frmCourierManagementSystem = new JFrame();
		frmCourierManagementSystem.setBounds(200, 10, 875, 700);
		frmCourierManagementSystem.setTitle("Courier Management System");
		frmCourierManagementSystem.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		tabbedPane = new JTabbedPane(JTabbedPane.TOP);
		
		frmCourierManagementSystem.getContentPane().add(tabbedPane, BorderLayout.CENTER);
		
		pnEmployees = new JPanel();
		tabbedPane.addTab("Employees", null, pnEmployees, null);
		pnEmployees.setLayout(new BorderLayout(0, 0));
		
		tabbedPaneEmployees = new JTabbedPane(JTabbedPane.TOP);
		pnEmployees.add(tabbedPaneEmployees, BorderLayout.CENTER);
		
		pnListEmployees = new JPanel();
		tabbedPaneEmployees.addTab("List", null, pnListEmployees, null);
		pnListEmployees.setLayout(null);	
		
		pnListTableEmployee = new JPanel();
		pnListTableEmployee.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnListTableEmployee.setBounds(21, 141, 440, 363);
		pnListEmployees.add(pnListTableEmployee);
		pnListTableEmployee.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane = new JScrollPane();
		pnListTableEmployee.add(scrollPane, BorderLayout.CENTER);
		tbList = new JTable();
		tbList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		tbList.setRowSelectionAllowed(true);
		modelTable = new DefaultTableModel(){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};
		
		tbList.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null},
			},
			new String[] {
				"ID", "Login name", "Name", "Function", "Status"
			}
		));
		scrollPane.setViewportView(tbList);
		
		tbList.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent evt)  
            {  
                if (evt.getClickCount() == 1)
                {
                    Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, tbList.getValueAt(tbList.getSelectedRow(), 1).toString(),btnInfoAvatar );
                    String tempAvatar = btnInfoAvatar.getIcon().toString().substring(btnInfoAvatar.getIcon().toString().lastIndexOf('/')+1,btnInfoAvatar.getIcon().toString().length());
                    if(tempAvatar.equals("anonymous.png"))
						infoAvatar = null;
					else infoAvatar = new File("emps\\"+tempAvatar);
                }
                if(evt.getClickCount()==2){
					
					int col = tbList.getSelectedColumn();
					if(col==0){
						JOptionPane.showMessageDialog(null, "You are not allowed to edit ID !");
					}
					if(col==1){
						JOptionPane.showMessageDialog(null, "You are not allowed to edit Login name!");
					}
					if(col==2){
						JOptionPane.showMessageDialog(null, "You are not allowed to edit Name in table!");
					}
					if(col==3){
						JOptionPane.showMessageDialog(null, "You are not allowed to edit Function in table!");
					}
					if(col==4){
						JOptionPane.showMessageDialog(null, "You are not allowed to Working status info in table!");
					}
				}
             }
		});
		
		tbList.addKeyListener(new KeyListener() {

			@Override
			public void keyPressed(KeyEvent e) {
				// TODO Auto-generated method stub
				if(e.getKeyCode()== KeyEvent.VK_UP){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoEmail,cbInfoFunction,tbList.getValueAt(tbList.getSelectedRow(), 1).toString(),btnInfoAvatar );
				}
				if(e.getKeyCode()== KeyEvent.VK_DOWN){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tbList.getValueAt(tbList.getSelectedRow(), 1).toString(),btnInfoAvatar );
				}
				
			}

			@Override
			public void keyReleased(KeyEvent e) {
				// TODO Auto-generated method stub
				if(e.getKeyCode()== KeyEvent.VK_UP){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoEmail,cbInfoFunction,tbList.getValueAt(tbList.getSelectedRow(), 1).toString(),btnInfoAvatar );
				}
				if(e.getKeyCode()== KeyEvent.VK_DOWN){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tbList.getValueAt(tbList.getSelectedRow(), 1).toString(),btnInfoAvatar );
				}
			}

			@Override
			public void keyTyped(KeyEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			
		});
		
		pnInfoEmployee = new JPanel();
		pnInfoEmployee.setBorder(new TitledBorder(null, "Info", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnInfoEmployee.setBounds(471, 38, 337, 439);
		pnListEmployees.add(pnInfoEmployee);
		pnInfoEmployee.setLayout(null);
		
		pnInfoAvatar = new JPanel();
		pnInfoAvatar.setBorder(null);
		pnInfoAvatar.setBounds(25, 22, 80, 80);
		pnInfoEmployee.add(pnInfoAvatar);
		pnInfoAvatar.setLayout(new BorderLayout(0, 0));
		
		btnInfoAvatar = new JButton("");
		btnInfoAvatar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(emp.getDecentralization() != 2)
					infoAvatar = Employee.changeAvatar(btnInfoAvatar);
			}
		});
		pnInfoAvatar.add(btnInfoAvatar, BorderLayout.CENTER);
		btnInfoAvatar.setToolTipText("Change avatar");
		ImageIcon iconInfoEmployee = new ImageIcon("images/anonymous.png");
		btnInfoAvatar.setIcon(iconInfoEmployee);
		
		tfInfoLoginName = new JTextField();
		tfInfoLoginName.setEditable(false);
		tfInfoLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfInfoLoginName.setBounds(116, 75, 188, 27);
		pnInfoEmployee.add(tfInfoLoginName);
		tfInfoLoginName.setColumns(10);
		
		lblInfoLoginName = new JLabel("Login name");
		lblInfoLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoLoginName.setBounds(115, 50, 129, 21);
		pnInfoEmployee.add(lblInfoLoginName);
		
		lblInfoName = new JLabel("Name");
		lblInfoName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoName.setBounds(11, 152, 96, 21);
		pnInfoEmployee.add(lblInfoName);
		
		tfInfoName = new JTextField();
		tfInfoName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfInfoName.setColumns(10);
		tfInfoName.setBounds(88, 150, 216, 27);
		pnInfoEmployee.add(tfInfoName);
		
		lblInfoPhone = new JLabel("Phone");
		lblInfoPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoPhone.setBounds(11, 260, 96, 21);
		pnInfoEmployee.add(lblInfoPhone);
		
		tfInfoPhone = new JTextField();
		tfInfoPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfInfoPhone.setColumns(10);
		tfInfoPhone.setBounds(88, 258, 216, 27);
		pnInfoEmployee.add(tfInfoPhone);
		
		lblInfoEmail = new JLabel("Email");
		lblInfoEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoEmail.setBounds(11, 294, 96, 21);
		pnInfoEmployee.add(lblInfoEmail);
		
		tfInfoEmail = new JTextField();
		tfInfoEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfInfoEmail.setColumns(10);
		tfInfoEmail.setBounds(88, 292, 129, 27);
		pnInfoEmployee.add(tfInfoEmail);
		
		cbInfoEmail = new JComboBox();
		cbInfoEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbInfoEmail.setModel(new DefaultComboBoxModel(new String[] {"@gmail.com", "@yahoo.com"}));
		cbInfoEmail.setBounds(227, 294, 101, 25);
		pnInfoEmployee.add(cbInfoEmail);
		
		lblInfoFunction = new JLabel("Function");
		lblInfoFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoFunction.setBounds(11, 328, 96, 21);
		pnInfoEmployee.add(lblInfoFunction);
		cbInfoFunction = new JComboBox();
		cbInfoFunction.setModel(new DefaultComboBoxModel(new String[] {"Administrator", "Enquiry Department", "Working Department", "Dispatch Department"}));
		cbInfoFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbInfoFunction.setBounds(88, 326, 188, 27);
		pnInfoEmployee.add(cbInfoFunction);

		lblInfoAddress = new JLabel("Address");
		lblInfoAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoAddress.setBounds(10, 184, 96, 21);
		pnInfoEmployee.add(lblInfoAddress);
		
		lblInfoWorkingStatus = new JLabel("Working status");
		lblInfoWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoWorkingStatus.setBounds(11, 362, 96, 21);
		pnInfoEmployee.add(lblInfoWorkingStatus);
		
		cbInfoWorkingStatus = new JComboBox();
		cbInfoWorkingStatus.setModel(new DefaultComboBoxModel(new String[] {"On probation", "Working", "On leave of absence", "Quit"}));
		cbInfoWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbInfoWorkingStatus.setBounds(116, 359, 188, 27);
		pnInfoEmployee.add(cbInfoWorkingStatus);
		
		lblInfoDateCreated = new JLabel("Date created");
		lblInfoDateCreated.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInfoDateCreated.setBounds(11, 115, 96, 21);
		pnInfoEmployee.add(lblInfoDateCreated);
		
		tfInfoDateCreated = new JTextField();
		tfInfoDateCreated.setEditable(false);
		tfInfoDateCreated.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfInfoDateCreated.setColumns(10);
		tfInfoDateCreated.setBounds(104, 113, 200, 27);
		pnInfoEmployee.add(tfInfoDateCreated);
		
		btnDeleteEmployee = new JButton("Delete");
		//Delete one employee
		btnDeleteEmployee.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(tbList.getSelectedRow()>-1){														
					int option = JOptionPane.showConfirmDialog(null, "Sure you want to delete this employee ?", "Confirm Question", JOptionPane.YES_NO_OPTION);
						// JOptionPane.YES_NO_CANCEL_OPTION;
						if(option==JOptionPane.YES_OPTION){
								Procedure.DelEmp(tbList.getValueAt(tbList.getSelectedRow(), 1).toString());								
								Attendance_Management.getAttendance(tableAttendance, emp.getLoginName(), new Date());
								modelTable = new DefaultTableModel();
								Procedure.List_Emp(modelTable, tbList, 1, "",emp.getLoginName(), 0, 0);
								JOptionPane.showMessageDialog(null, "Deleted !");	
								if(tbList.getRowCount() != 0)
								{
									tbList.changeSelection(0, 0, false, false);
									Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tbList.getValueAt(0, 1).toString(),btnInfoAvatar );
								}
								else
								{
									tfInfoLoginName.setText("");
									lbInfoIndexID.setText("");
									tfInfoName.setText("");
									tfInfoPhone.setText("");
									taInfoAddress.setText("");
									tfInfoEmail.setText("");	
									tfInfoDateCreated.setText("");
									cbInfoWorkingStatus.setSelectedIndex(0);
									cbInfoFunction.setSelectedIndex(0);
									cbInfoEmail.setSelectedIndex(0);
									ImageIcon anonymous = new ImageIcon("images/anonymous.png");
									btnInfoAvatar.setIcon(anonymous);
								}
						}
											
				}else{
					JOptionPane.showMessageDialog(null, "You must choose one in table!");
				}
			}
		});
		btnDeleteEmployee.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnDeleteEmployee.setBounds(40, 401, 96, 27);
		pnInfoEmployee.add(btnDeleteEmployee);
		
		btnEditEmployee = new JButton("Edit");
		btnEditEmployee.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				int option = JOptionPane.showConfirmDialog(null, "Sure you want to update?","Warning",JOptionPane.YES_NO_OPTION);
				if(option == JOptionPane.YES_OPTION)
				{
					if(tbList.getSelectedRow()>-1){
						if(!lbInfoIndexID.getText().trim().equals("")&&!tfInfoLoginName.getText().trim().equals("")&&!tfInfoName.getText().trim().equals("")&&!taInfoAddress.getText().trim().equals("")&&!tfInfoPhone.getText().trim().equals("")){
							if(tfInfoPhone.getText().matches(("(?=[^A-Za-z]+$).*[0-9].*")) && Integer.parseInt(tfInfoPhone.getText()) >= 0)
							{
							String pathAvatar = CreateAccount.Avatar(tfInfoLoginName.getText(), infoAvatar,pnInfoAvatar);
							Procedure.UpdateInfo(tfInfoLoginName.getText(), tfInfoName.getText(), taInfoAddress.getText(), Integer.parseInt(tfInfoPhone.getText()),tfInfoEmail.getText()+cbInfoEmail.getSelectedItem().toString(),pathAvatar,cbInfoFunction.getSelectedIndex()+1,cbInfoWorkingStatus.getSelectedIndex());
							modelTable = new DefaultTableModel();
							int tempRow = tbList.getSelectedRow();
							int tempStatus = cbInfoWorkingStatus.getSelectedIndex();
							Procedure.List_Emp(modelTable, tbList, 1, "",emp.getLoginName(), 0, 0);
							if(tempStatus == 3)
							{
								if(tbList.getRowCount() != 0)
								{
									tbList.changeSelection(0, 0, false, false);
									Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tbList.getValueAt(0, 1).toString(),btnInfoAvatar );
								}
								else
								{
									tfInfoLoginName.setText("");
									lbInfoIndexID.setText("");
									tfInfoName.setText("");
									tfInfoPhone.setText("");
									taInfoAddress.setText("");
									tfInfoEmail.setText("");	
									tfInfoDateCreated.setText("");
									cbInfoWorkingStatus.setSelectedIndex(0);
									cbInfoFunction.setSelectedIndex(0);
									cbInfoEmail.setSelectedIndex(0);
									ImageIcon anonymous = new ImageIcon("images/anonymous.png");
									btnInfoAvatar.setIcon(anonymous);
								}
							} else
							{
								tbList.changeSelection(tempRow, 0, false, false);
								if(tbList.getSelectedRow() == 0)
									tbList.changeSelection(0, 0, false, false);
							}
							Attendance_Management.getAttendance(tableAttendance, emp.getLoginName(), new Date());
							JOptionPane.showMessageDialog(null, "Updated successfully!!!");	
							} else JOptionPane.showMessageDialog(null, "Phone must contain numbers only!");
						}else{
							JOptionPane.showMessageDialog(null, "All blanks must be filled in!!!");
						}
					}else{
						JOptionPane.showMessageDialog(null, "You must choose one in table!!");
					}
				}
			}
		});
		btnEditEmployee.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnEditEmployee.setBounds(193, 401, 96, 27);
		pnInfoEmployee.add(btnEditEmployee);
		
		final JLabel lblInfoID = new JLabel("ID :");
		lblInfoID.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblInfoID.setBounds(115, 22, 33, 21);
		pnInfoEmployee.add(lblInfoID);
		
		lbInfoIndexID = new JLabel("");
		lbInfoIndexID.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lbInfoIndexID.setBounds(147, 22, 146, 21);
		pnInfoEmployee.add(lbInfoIndexID);
		scrollPane_4 = new JScrollPane();
		scrollPane_4.setBounds(88, 184, 216, 65);
		pnInfoEmployee.add(scrollPane_4);
		
		taInfoAddress = new JTextArea();
		scrollPane_4.setViewportView(taInfoAddress);
		taInfoAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		taInfoAddress.setTabSize(4);
		taInfoAddress.setLineWrap(true);
		taInfoAddress.setRows(4);
		
		pnFindEmployee = new JPanel();
		
		pnFindEmployee.setBorder(new TitledBorder(null, "Find", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnFindEmployee.setBounds(21, 11, 440, 119);
		pnListEmployees.add(pnFindEmployee);
		pnFindEmployee.setLayout(null);
		
		lblFindLoginName = new JLabel("Login name");
		lblFindLoginName.setBounds(29, 24, 102, 16);
		lblFindLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		pnFindEmployee.add(lblFindLoginName);
		
		tfFindLoginName = new JTextField();
		tfFindLoginName.setBounds(134, 21, 152, 22);
		tfFindLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfFindLoginName.setColumns(10);
		pnFindEmployee.add(tfFindLoginName);
		
		lblFindFunction = new JLabel("Fuction");
		lblFindFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblFindFunction.setBounds(29, 50, 96, 21);
		pnFindEmployee.add(lblFindFunction);
		
		cbFindFunction = new JComboBox();
		cbFindFunction.setModel(new DefaultComboBoxModel(new String[] {"President","Administrator","Enquiry Department", "Working Department", "Dispatch Department","All"}));
		cbFindFunction.setSelectedIndex(5);
		cbFindFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbFindFunction.setBounds(134, 47, 188, 27);
		pnFindEmployee.add(cbFindFunction);
		
		lblFindWorkingStatus = new JLabel("Working status");
		lblFindWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblFindWorkingStatus.setBounds(29, 84, 96, 21);
		pnFindEmployee.add(lblFindWorkingStatus);
		
		cbFindWorkingStatus = new JComboBox();
		cbFindWorkingStatus.setModel(new DefaultComboBoxModel(new String[]{"On probation","Working","On leave of absence","Quit","All"}));
		cbFindWorkingStatus.setSelectedIndex(4);
		cbFindWorkingStatus.setSelectedIndex(4);
		cbFindWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbFindWorkingStatus.setBounds(134, 81, 188, 27);
		pnFindEmployee.add(cbFindWorkingStatus);
		
		btnFindEmployee = new JButton("Find");
		//show info about Employee
		btnFindEmployee.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				modelTable = new DefaultTableModel(){					
					public boolean isCellEditable(int row, int col){
						return false;
					}				
				};
				
				if(Procedure.FindEmp(tfFindLoginName.getText())==1){
					if(tfFindLoginName.getText().equalsIgnoreCase(emp.getLoginName())){
						JOptionPane.showMessageDialog(null, "Please check your own information in tab MyInfo");
					}else{						
						Procedure.List_Emp(modelTable, tbList, 0, tfFindLoginName.getText(),tfMyInfoLoginName.getText(),cbFindFunction.getSelectedIndex(),cbFindWorkingStatus.getSelectedIndex());
					}
				}else{
					if(String.valueOf(cbFindFunction.getSelectedItem()).equals("All")&&String.valueOf(cbFindWorkingStatus.getSelectedItem()).equals("All")){		
						
						Procedure.List_Emp(modelTable, tbList, 1,"", tfMyInfoLoginName.getText(),-1,-1);
					}
					if(!String.valueOf(cbFindFunction.getSelectedItem()).equals("All")&&String.valueOf(cbFindWorkingStatus.getSelectedItem()).equals("All")){		
						Procedure.List_Emp(modelTable, tbList, 2,"", tfMyInfoLoginName.getText(),cbFindFunction.getSelectedIndex(),-1);
					}
					if(String.valueOf(cbFindFunction.getSelectedItem()).equals("All")&&!String.valueOf(cbFindWorkingStatus.getSelectedItem()).equals("All")){								
						Procedure.List_Emp(modelTable, tbList, 3,"", tfMyInfoLoginName.getText(),-1,cbFindWorkingStatus.getSelectedIndex());
					}
					if(!String.valueOf(cbFindFunction.getSelectedItem()).equals("All")&&!String.valueOf(cbFindFunction.getSelectedItem()).equals("All")){							 
						Procedure.List_Emp(modelTable, tbList, 4,"", tfMyInfoLoginName.getText(),cbFindFunction.getSelectedIndex(),cbFindWorkingStatus.getSelectedIndex());
					}
				}	
					
					tfFindLoginName.setText("");	
			}
		});	
		
		
		
		btnFindEmployee.setBounds(339, 32, 91, 27);
		pnFindEmployee.add(btnFindEmployee);
		
		btnShowAllEmployees = new JButton("Show all");
		btnShowAllEmployees.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				modelTable = new DefaultTableModel(){					
					public boolean isCellEditable(int row, int col){
						return false;
					}				
				};
			
				Procedure.List_Emp(modelTable, tbList, 2,"", tfMyInfoLoginName.getText(),-1,-1);
				cbFindFunction.setSelectedIndex(5);
				cbFindWorkingStatus.setSelectedIndex(4);
			}
		});
		btnShowAllEmployees.setBounds(339, 70, 91, 27);
		pnFindEmployee.add(btnShowAllEmployees);
		ImageIcon iconAddEmployee = new ImageIcon("images/anonymous.png");
			
		final JComboBox cbAddEmail = new JComboBox();
		cbAddEmail.setModel(new DefaultComboBoxModel(new String[] {"@gmail.com", "@yahoo.com"}));
		cbAddEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbAddEmail.setBounds(250, 325, 101, 25);		

		JScrollPane scrollPane_3 = new JScrollPane();
		scrollPane_3.setBounds(112, 217, 217, 65);
		//panelAddEmpployee.add(scrollPane_3);
//		
		
		
		pnCouriers = new JPanel();
		tabbedPane.addTab("Couriers", null, pnCouriers, null);
		pnCouriers.setLayout(new BorderLayout(0, 0));
		
		tabbedPaneCouriers = new JTabbedPane(JTabbedPane.TOP);
		pnCouriers.add(tabbedPaneCouriers, BorderLayout.CENTER);
		
		pnCouManagement = new JPanel();
		tabbedPaneCouriers.addTab("Management", null, pnCouManagement, null);
		pnCouManagement.setLayout(null);
		
		pnFindCourier = new JPanel();
		pnFindCourier.setLayout(null);
		pnFindCourier.setBorder(new TitledBorder(null, "Find", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnFindCourier.setBounds(10, 11, 635, 119);
		pnCouManagement.add(pnFindCourier);
		
//		JPanel plFindCourier = new JPanel();
//		plFindCourier.setLayout(null);
//		plFindCourier.setBorder(new TitledBorder(null, "Find", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
//		plFindCourier.setBounds(10, 11, 635, 119);
//		panel_4.add(plFindCourier);
//		
		lbCoFindCourierName = new JLabel("Courier name");
		lbCoFindCourierName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoFindCourierName.setBounds(10, 36, 102, 16);
		pnFindCourier.add(lbCoFindCourierName);
		
		tfFindCNum = new JTextField();
		tfFindCNum.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfFindCNum.setColumns(10);
		tfFindCNum.setBounds(115, 33, 125, 21);
		pnFindCourier.add(tfFindCNum);
		
		lbCoFindLoginName = new JLabel("Login name");
		lbCoFindLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoFindLoginName.setBounds(10, 70, 96, 21);
		pnFindCourier.add(lbCoFindLoginName);
		
		btnfindCourier = new JButton("Find");
		btnfindCourier.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
			//	java.sql.Date sqlDate = new java.sql.Date();
				if(tfFindDate.getDate()==null){
					Courier_Management.find(tbCouShow,tfFindCNum.getText() , tfFindSName.getText(), tfFindRName.getText(), tfFindLName.getText());
				}
				else{
				//============================
					SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
					Date getuntilDate = null;
					try {
						getuntilDate = formatter.parse(formatter.format(tfFindDate.getDate()));
					} catch (ParseException e1) {
						// TODO Auto-generated catch block
						e1.printStackTrace();
					}
					java.sql.Date sqlDateuntil = new java.sql.Date(getuntilDate.getTime());
					//==========================
					tfFindDate.setDate(null);
					Courier_Management.find(tbCouShow,tfFindCNum.getText() , tfFindSName.getText(), tfFindRName.getText(), tfFindLName.getText(),sqlDateuntil);
			}
			}
		});
		btnfindCourier.setBounds(513, 33, 91, 27);
		pnFindCourier.add(btnfindCourier);
		

		btnShowAllCourier = new JButton("Show all");
		btnShowAllCourier.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Courier_Management.GetAllCouier(tbCouShow);
			}
		});
		btnShowAllCourier.setBounds(513, 69, 91, 27);
		pnFindCourier.add(btnShowAllCourier);

		tfFindLName = new JTextField();
		tfFindLName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfFindLName.setColumns(10);
		tfFindLName.setBounds(115, 71, 125, 21);
		pnFindCourier.add(tfFindLName);
		

		lbCoFindNameSender = new JLabel("Name of sender");
		lbCoFindNameSender.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoFindNameSender.setBounds(266, 59, 102, 16);
		pnFindCourier.add(lbCoFindNameSender);

		lbCoFindNameReceiver = new JLabel("Name of receiver");
		lbCoFindNameReceiver.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoFindNameReceiver.setBounds(266, 86, 102, 21);
		pnFindCourier.add(lbCoFindNameReceiver);

		tfFindRName = new JTextField();
		tfFindRName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfFindRName.setColumns(10);
		tfFindRName.setBounds(378, 87, 116, 21);
		pnFindCourier.add(tfFindRName);
		
		tfFindSName = new JTextField();
		tfFindSName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfFindSName.setColumns(10);
		tfFindSName.setBounds(378, 56, 116, 21);
		pnFindCourier.add(tfFindSName);
		
	
		
		lblDate_2 = new JLabel("Date");
		lblDate_2.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblDate_2.setBounds(307, 26, 102, 16);
		pnFindCourier.add(lblDate_2);
		
		tfFindDate = new JXDatePicker();
		tfFindDate.setBounds(378, 24, 116, 23);
		pnFindCourier.add(tfFindDate);
		tfFindDate.setDate(Calendar.getInstance().getTime());
		tfFindDate.setFormats(new SimpleDateFormat("dd-MM-yyyy"));
		
	
		JPanel panel_6 = new JPanel();
		panel_6.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		panel_6.setBounds(10, 136, 352, 397);
		pnCouManagement.add(panel_6);
		panel_6.setLayout(new BorderLayout(0, 0));
		
		
//=======
//		pnListCouriers = new JPanel();
//		pnListCouriers.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
//		pnListCouriers.setBounds(10, 136, 352, 397);
//		panel_4.add(pnListCouriers);
//		pnListCouriers.setLayout(new BorderLayout(0, 0));
//>>>>>>> .r48
//		
		JScrollPane scrollPane_2 = new JScrollPane();
		panel_6.add(scrollPane_2, BorderLayout.CENTER);
	
		tbCouShow = new JTable();
		tbCouShow.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		tbCouShow.setRowSelectionAllowed(true);
		modelTable = new DefaultTableModel(){
			public boolean isCellEditable(int row, int col){
				return false;
			}
		};

			tbCouShow.setModel(new DefaultTableModel(
				new Object[][] {
					{null, null, null, null},
				},
				new String[] {
					"Courier name", "Sender name", "Receiver name", "Login name"
				}
			));
		scrollPane_2.setViewportView(tbCouShow);

		tbCouShow.addMouseListener(new MouseListener() {
			
			@Override
			public void mouseReleased(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mousePressed(MouseEvent e) {
				if(e.getClickCount()==1){
					if(emp.getDecentralization() == 4)
						check(1);
					if(emp.getDecentralization() == 3 || emp.getDecentralization() == 0)
					{
						check(3);
						rdbtnCouUpdate.setSelected(true);
					}
					if(emp.getDecentralization() == 2)
						check(5);
					assign(Courier_Management.Info_Courier((String)tbCouShow.getValueAt(tbCouShow.getSelectedRow(),0)));
					}
				if(e.getClickCount()==2){
					int row = tbCouShow.getSelectedRow();
					int col = tbCouShow.getSelectedColumn();
					if((col==0 ||col ==1|| col==2|| col==3)){
						JOptionPane.showMessageDialog(null, "You don't have permition to fix that");
						//tbCouShow.isCellEditable(row, col);
						//tbCouShow.setEnabled(false);
					
					}
				}
				}
			
			@Override
			public void mouseExited(MouseEvent e) {
				// TODO Auto-generated method stub
				
			}
			
			@Override
			public void mouseEntered(MouseEvent e) {
			
								
			}
			
			@Override
			public void mouseClicked(MouseEvent e) {
				
			}
		});
	
		pnCourierService = new JPanel();
		pnCourierService.setLayout(null);
		pnCourierService.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Courier Service", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnCourierService.setBounds(670, 11, 167, 119);
		pnCouManagement.add(pnCourierService);
		
		rdbtnCouUpdate = new JRadioButton("Update");
		buttonGroup_1.add(rdbtnCouUpdate);
		rdbtnCouUpdate.setFont(new Font("Tahoma", Font.PLAIN, 15));
		rdbtnCouUpdate.setBounds(27, 31, 109, 23);
		pnCourierService.add(rdbtnCouUpdate);
		rdbtnCouUpdate.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				tempCheckCouRadio = 1;
				if(emp.getDecentralization() == 4)
					check(1);
				if(emp.getDecentralization() == 3 || emp.getDecentralization() == 0)
					check(3);
				if(emp.getDecentralization() == 2)
					check(5);
			}
		});
		rdbtnCouNew = new JRadioButton("New");
		buttonGroup_1.add(rdbtnCouNew);
		rdbtnCouNew.setFont(new Font("Tahoma", Font.PLAIN, 15));
		rdbtnCouNew.setBounds(27, 57, 109, 23);
		pnCourierService.add(rdbtnCouNew);
		rdbtnCouNew.setSelected(true);
		rdbtnCouNew.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				tempCheckCouRadio = 2;
				tbCouShow.clearSelection();
				check(3);
				check(4);
				rdbtnCouDelete.setEnabled(false);
				rdbtnCouUpdate.setEnabled(false);
				
			}
		});
		
		rdbtnCouDelete = new JRadioButton("Delete");
		buttonGroup_1.add(rdbtnCouDelete);
		rdbtnCouDelete.setFont(new Font("Tahoma", Font.PLAIN, 15));
		rdbtnCouDelete.setBounds(27, 83, 109, 23);
		pnCourierService.add(rdbtnCouDelete);
		rdbtnCouDelete.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent e) {
				tempCheckCouRadio = 3;
				check(2);
			}
		});
		
		pnInfoCourier = new JPanel();
		pnInfoCourier.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Info", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnInfoCourier.setBounds(372, 141, 465, 397);
		pnCouManagement.add(pnInfoCourier);
		pnInfoCourier.setLayout(null);
		
		lbCoInfoCourierName = new JLabel("Courier name");
		lbCoInfoCourierName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoInfoCourierName.setBounds(10, 64, 96, 21);
		pnInfoCourier.add(lbCoInfoCourierName);
		
		lbCoInfoLoginName = new JLabel("Login name");
		lbCoInfoLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoInfoLoginName.setBounds(10, 101, 96, 21);
		pnInfoCourier.add(lbCoInfoLoginName);
		
		tfCourierInfo_CourierNumber = new JTextField();
		tfCourierInfo_CourierNumber.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCourierInfo_CourierNumber.setEditable(false);
		tfCourierInfo_CourierNumber.setColumns(10);
		tfCourierInfo_CourierNumber.setBounds(116, 61, 116, 27);
		tfCourierInfo_CourierNumber.setText(Courier_Management.CourierName());
		pnInfoCourier.add(tfCourierInfo_CourierNumber);
		
		tfCouLoginName = new JTextField();
		tfCouLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCouLoginName.setEditable(false);
		tfCouLoginName.setColumns(10);
		tfCouLoginName.setBounds(116, 102, 116, 27);
		tfCouLoginName.setText(emp.getLoginName());
		pnInfoCourier.add(tfCouLoginName);
		
		lbCoInfoStatus = new JLabel("Status");
		lbCoInfoStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoInfoStatus.setBounds(248, 24, 84, 21);
		pnInfoCourier.add(lbCoInfoStatus);
		
		lbCoInfoAmount = new JLabel("Amount");
		lbCoInfoAmount.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoInfoAmount.setBounds(248, 101, 96, 21);
		pnInfoCourier.add(lbCoInfoAmount);
		
		tfCou_Amount = new JTextField();
		tfCou_Amount.setEnabled(false);
		tfCou_Amount.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCou_Amount.setColumns(10);
		tfCou_Amount.setBounds(328, 100, 84, 27);
		pnInfoCourier.add(tfCou_Amount);
		
		pnCouSender = new JPanel();
		pnCouSender.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "About sender", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 15), null));
		pnCouSender.setBounds(10, 146, 222, 203);
		pnInfoCourier.add(pnCouSender);
		pnCouSender.setLayout(null);
		
		lbSenderName = new JLabel("Name");
		lbSenderName.setBounds(10, 26, 96, 21);
		pnCouSender.add(lbSenderName);
		lbSenderName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		
		tfCouSName = new JTextField();
		tfCouSName.setBounds(60, 23, 129, 27);
		pnCouSender.add(tfCouSName);
		tfCouSName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCouSName.setColumns(10);
		
		lbSenderAddress = new JLabel("Address");
		lbSenderAddress.setBounds(10, 58, 96, 21);
		pnCouSender.add(lbSenderAddress);
		lbSenderAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
	

		lbSenderLocation = new JLabel("Province/City");
		lbSenderLocation.setBounds(10, 133, 96, 21);
		pnCouSender.add(lbSenderLocation);
		lbSenderLocation.setFont(new Font("Tahoma", Font.PLAIN, 13));
		
		tfCouSPhone = new JTextField();
		tfCouSPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCouSPhone.setColumns(10);
		tfCouSPhone.setBounds(93, 166, 111, 27);
		pnCouSender.add(tfCouSPhone);
		
		lbSenderPhone = new JLabel("Phone");
		lbSenderPhone.setBounds(10, 169, 96, 21);
		pnCouSender.add(lbSenderPhone);
		lbSenderPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		
		cbCouSProvince = new JComboBox();
		cbCouSProvince.setBounds(93, 134, 111, 24);
		cbCouSProvince.setModel(new DefaultComboBoxModel<String>(listLocs));
		cbCouSProvince.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				if(rdbtnCouNew.isSelected()){
				cbCouStatus.setSelectedItem(cbCouSProvince.getSelectedItem());
				}
				if(tfCouWeight.getText().equals("")){}
				else
				tfCou_Amount.setText(String.valueOf(Courier_Management.calculate(cbCouSProvince.getSelectedIndex(), cbCouRProvince.getSelectedIndex(), Float.parseFloat(tfCouWeight.getText()))));
;			}
		});
		pnCouSender.add(cbCouSProvince);
		
		JScrollPane scrollPane_9 = new JScrollPane();
		scrollPane_9.setBounds(63, 60, 144, 65);
		pnCouSender.add(scrollPane_9);
		
		taCouSAddress = new JTextArea();
		scrollPane_9.setViewportView(taCouSAddress);
		taCouSAddress.setTabSize(4);
		taCouSAddress.setRows(4);
		taCouSAddress.setLineWrap(true);
		taCouSAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		
		pnCouReceiver = new JPanel();
		pnCouReceiver.setLayout(null);
		pnCouReceiver.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "About receiver", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 15), null));
		pnCouReceiver.setBounds(233, 146, 222, 203);
		pnInfoCourier.add(pnCouReceiver);
		
		lbReceiverName = new JLabel("Name");
		lbReceiverName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbReceiverName.setBounds(10, 26, 96, 21);
		pnCouReceiver.add(lbReceiverName);
		
		tfCouRName = new JTextField();
		tfCouRName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCouRName.setColumns(10);
		tfCouRName.setBounds(60, 23, 129, 27);
		pnCouReceiver.add(tfCouRName);
		
		lbReceiverAddress = new JLabel("Address");
		lbReceiverAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbReceiverAddress.setBounds(10, 58, 96, 21);
		pnCouReceiver.add(lbReceiverAddress);
		
		lbReceiverLocation = new JLabel("Province/City");
		lbReceiverLocation.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbReceiverLocation.setBounds(10, 133, 96, 21);
		pnCouReceiver.add(lbReceiverLocation);
		
		tfCouRPhone = new JTextField();
		tfCouRPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCouRPhone.setColumns(10);
		tfCouRPhone.setBounds(93, 166, 111, 27);
		pnCouReceiver.add(tfCouRPhone);
		
		lbReceiverPhone = new JLabel("Phone");
		lbReceiverPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbReceiverPhone.setBounds(10, 169, 96, 21);
		pnCouReceiver.add(lbReceiverPhone);
		
		cbCouRProvince = new JComboBox();
		cbCouRProvince.setBounds(93, 134, 111, 24);
		cbCouRProvince.setModel(new DefaultComboBoxModel<String>(listLocs));
		pnCouReceiver.add(cbCouRProvince);
		
		JScrollPane scrollPane_10 = new JScrollPane();
		scrollPane_10.setBounds(61, 62, 144, 65);
		pnCouReceiver.add(scrollPane_10);
		
		taCouRAddress = new JTextArea();
		scrollPane_10.setViewportView(taCouRAddress);
		taCouRAddress.setTabSize(4);
		taCouRAddress.setRows(4);
		taCouRAddress.setLineWrap(true);
		taCouRAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbCouRProvince.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				tfCou_Amount.setText(String.valueOf(Courier_Management.calculate(cbCouSProvince.getSelectedIndex(), cbCouRProvince.getSelectedIndex(), Float.parseFloat(tfCouWeight.getText()))));
			}
		});
		
		btnCourierInfo_OK = new JButton("OK");
		btnCourierInfo_OK.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try{
					int option = JOptionPane.showConfirmDialog(null, "Are you sure?","Message",JOptionPane.YES_NO_OPTION);
					if(option == JOptionPane.YES_OPTION)
						if(rdbtnCouNew.isSelected() ==true){	
							if(check_input()==1){
								
								java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
									cr =Courier_Management.Assign_Courier(tfCourierInfo_CourierNumber.getText(),sqlDate, tfCouSName.getText(),Double.parseDouble(tfCouSPhone.getText()), taCouSAddress.getText(), tfCouRName.getText(), Double.parseDouble(tfCouRPhone.getText()), taCouRAddress.getText(), Float.parseFloat(tfCou_Amount.getText()), cbCouStatus.getSelectedIndex(), tfCouLoginName.getText(),Float.parseFloat(tfCouWeight.getText()),cbCouSProvince.getSelectedIndex(),cbCouRProvince.getSelectedIndex());
									Courier_Management.Add_Courier(cr);
									Courier_Management.IncreaseID();
									tfCourierInfo_CourierNumber.setText(Courier_Management.CourierName());
									check(4);
									Courier_Management.get_cou_has_not_done(tbCouShow);
							}else {
									JOptionPane.showMessageDialog(null, "YOU MUST FILL IN ALL THE PLAN!");	
									}		
						}else if(rdbtnCouUpdate.isSelected()==true){
								if(tbCouShow.getSelectedRow() != -1)	
								{
									if(emp.getDecentralization()==3){
										//============================
										SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
										Date getuntilDate = null;
										try {
											getuntilDate = formatter.parse(formatter.format(tfcouDatetime.getDate()));
										} catch (ParseException e1) {
											// TODO Auto-generated catch block
											e1.printStackTrace();
										}
										java.sql.Date sqlDateuntil = new java.sql.Date(getuntilDate.getTime());
										//==========================
										cr =Courier_Management.Assign_Courier(tfCourierInfo_CourierNumber.getText(),sqlDateuntil, tfCouSName.getText(),Double.parseDouble(tfCouSPhone.getText()), taCouSAddress.getText(), tfCouRName.getText(), Double.parseDouble(tfCouRPhone.getText()), taCouRAddress.getText(), Float.parseFloat(tfCou_Amount.getText()), cbCouStatus.getSelectedIndex(), tfCouLoginName.getText(),Float.parseFloat(tfCouWeight.getText()),cbCouSProvince.getSelectedIndex(),cbCouRProvince.getSelectedIndex());
										Courier_Management.Update_Working(cr);
										Courier_Management.get_cou_has_not_done(tbCouShow);
									}else if(emp.getDecentralization()==4){
										Courier_Management.Update_Dispatching(tfCourierInfo_CourierNumber.getText(), cbCouStatus.getSelectedIndex());
										Courier_Management.get_cou_has_not_done(tbCouShow);
									}
								}
								else 
									JOptionPane.showMessageDialog(null, "Please choose courier in table you want to update !");
								}
						else if(rdbtnCouDelete.isSelected()==true){
							if(tfFindCNum.getText().equals("") && tfFindDate.getDate()==null && tfFindLName.getText().equals("") && tfFindRName.getText().equals("") &&tfFindSName.getText().equals("")){
								Courier_Management.Del_Courier(tfCourierInfo_CourierNumber.getText());
								Courier_Management.get_cou_has_not_done(tbCouShow);
							}else{
								Courier_Management.Del_Courier(tfCourierInfo_CourierNumber.getText());
								if(tfFindDate.getDate()==null){
									Courier_Management.find(tbCouShow,tfFindCNum.getText() , tfFindSName.getText(), tfFindRName.getText(), tfFindLName.getText());
								}
								else{
								//============================
									SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
									Date getuntilDate = null;
									try {
										getuntilDate = formatter.parse(formatter.format(tfFindDate.getDate()));
									} catch (ParseException e1) {
										// TODO Auto-generated catch block
										e1.printStackTrace();
									}
									java.sql.Date sqlDateuntil = new java.sql.Date(getuntilDate.getTime());
									//==========================
									tfFindDate.setDate(null);
									Courier_Management.find(tbCouShow,tfFindCNum.getText() , tfFindSName.getText(), tfFindRName.getText(), tfFindLName.getText(),sqlDateuntil);
							}
				
							}
							check(4);
						}
				}catch(Exception ex){
					JOptionPane.showMessageDialog(null, "Phone or weight must be a number");
				}
			}
		});
		btnCourierInfo_OK.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnCourierInfo_OK.setBounds(188, 358, 84, 21);
		pnInfoCourier.add(btnCourierInfo_OK);
		
		lbCoInfoDateCreated = new JLabel("Date created");
		lbCoInfoDateCreated.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoInfoDateCreated.setBounds(10, 24, 96, 21);
		pnInfoCourier.add(lbCoInfoDateCreated);
		
		lbCoInfoWeight = new JLabel("Weight");
		lbCoInfoWeight.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbCoInfoWeight.setBounds(248, 64, 84, 21);
		pnInfoCourier.add(lbCoInfoWeight);
		
		tfCouWeight = new JTextField();
		tfCouWeight.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCouWeight.setColumns(10);
		tfCouWeight.setBounds(328, 59, 84, 27);
		pnInfoCourier.add(tfCouWeight);
		tfCouWeight.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				try{
				tfCou_Amount.setText(String.valueOf(Courier_Management.calculate(cbCouSProvince.getSelectedIndex(), cbCouRProvince.getSelectedIndex(), Float.parseFloat(tfCouWeight.getText()))));
				}catch(Exception ex){
					JOptionPane.showMessageDialog(null, "Weight must be a number");
					tfCouWeight.setText("0");
				}
			}
		});
		
		cbCouStatus = new JComboBox();
		cbCouStatus.setBounds(328, 23, 111, 24);
		cbCouStatus.setModel(new DefaultComboBoxModel<String>(listLocs));
		pnInfoCourier.add(cbCouStatus);
		
		tfcouDatetime = new JXDatePicker();
		tfcouDatetime.getEditor().setEditable(false);
		tfcouDatetime.setBounds(95, 22, 143, 27);
		pnInfoCourier.add(tfcouDatetime);
		tfcouDatetime.setDate(Calendar.getInstance().getTime());
		tfcouDatetime.setFormats(new SimpleDateFormat("dd-MM-yyyy"));
		
		JLabel lblKg = new JLabel("Kg");
		lblKg.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblKg.setBounds(422, 64, 46, 21);
		pnInfoCourier.add(lblKg);
		
		JLabel lblInr = new JLabel("INR");
		lblInr.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblInr.setBounds(422, 101, 46, 21);
		pnInfoCourier.add(lblInr);
		
		pnCouCalculator = new JPanel();
		tabbedPaneCouriers.addTab("Calculator", null, pnCouCalculator, null);
		pnCouCalculator.setLayout(null);
		
		pnAddNewRoute = new JPanel();
		pnAddNewRoute.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Add new route", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnAddNewRoute.setBounds(329, 20, 284, 171);
		pnCouCalculator.add(pnAddNewRoute);
		pnAddNewRoute.setLayout(null);
		
		lbFrom = new JLabel("From :");
		lbFrom.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbFrom.setBounds(10, 34, 46, 14);
		pnAddNewRoute.add(lbFrom);
		
		lbTo = new JLabel("To :");
		lbTo.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbTo.setBounds(10, 67, 46, 14);
		pnAddNewRoute.add(lbTo);
		cbCal_R_province = new JComboBox();
		cbCal_R_province.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbCal_R_province.setBounds(111, 62, 142, 27);
		cbCal_R_province.setModel(new DefaultComboBoxModel<>(listLocs));
		pnAddNewRoute.add(cbCal_R_province);
		
		lbDistance = new JLabel("Distance :");
		lbDistance.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbDistance.setBounds(10, 96, 78, 14);
		pnAddNewRoute.add(lbDistance);
		
		
		tfCalDistance = new JTextField();
		tfCalDistance.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent e) {
				if(e.getKeyCode() == KeyEvent.VK_ENTER)
				{
					if(tfCalDistance.getText().equals("0")){
						JOptionPane.showMessageDialog(null, "Distance can't be zero");
						}
					else if(cbCal_R_province.getSelectedIndex() == cbCal_S_province.getSelectedIndex()){
						JOptionPane.showMessageDialog(null, "Can't add distance to same city");
					}
					else{
						try{
							int option = JOptionPane.showConfirmDialog(null, "Sure you want to add a new route ?","Warning",JOptionPane.YES_NO_OPTION);
							if(option == JOptionPane.YES_OPTION)
							{
								Courier_Management.add_distance(cbCal_S_province.getSelectedIndex(), cbCal_R_province.getSelectedIndex(),Float.parseFloat(tfCalDistance.getText()));
							}
							}catch(Exception ex){
								JOptionPane.showMessageDialog(null, "Distance must be a number");
								tfCalDistance.setText("0");
								
							}
					table_2.setModel(Procedure.showRoads());
					}
				}
			}
		});
		tfCalDistance.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCalDistance.setText("0");
		tfCalDistance.setBounds(111, 91, 96, 27);
		pnAddNewRoute.add(tfCalDistance);
		tfCalDistance.setColumns(10);
		
		cbCal_S_province = new JComboBox();
		cbCal_S_province.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbCal_S_province.setBounds(111, 31, 142, 27);
		cbCal_S_province.setModel(new DefaultComboBoxModel<>(listLocs));
		pnAddNewRoute.add(cbCal_S_province);

		

		btnAddNewRoute = new JButton("Add");
		btnAddNewRoute.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				if(tfCalDistance.getText().equals("0")){
					JOptionPane.showMessageDialog(null, "Distance can't be a zero");
					}
				else if(cbCal_R_province.getSelectedIndex() == cbCal_S_province.getSelectedIndex()){
					JOptionPane.showMessageDialog(null, "Can't add distance to same city");
				}
				else{
					try{
						int option = JOptionPane.showConfirmDialog(null, "Sure you want to add a new route ?","Warning",JOptionPane.YES_NO_OPTION);
						if(option == JOptionPane.YES_OPTION)
						{
							Courier_Management.add_distance(cbCal_S_province.getSelectedIndex(), cbCal_R_province.getSelectedIndex(),Float.parseFloat(tfCalDistance.getText()));
						}
						}catch(Exception ex){
							JOptionPane.showMessageDialog(null, "Distance must be a number");
							tfCalDistance.setText("0");
							
						}
				table_2.setModel(Procedure.showRoads());
				}
				
			}
		});

		btnAddNewRoute.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAddNewRoute.setBounds(157, 129, 96, 27);
		pnAddNewRoute.add(btnAddNewRoute);

		
		pnAddNewLocation = new JPanel();
		pnAddNewLocation.setLayout(null);
		pnAddNewLocation.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Add new location", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnAddNewLocation.setBounds(23, 20, 284, 121);
		pnCouCalculator.add(pnAddNewLocation);
		
//		JPanel panel_14 = new JPanel();
//		panel_14.setLayout(null);
//		panel_14.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Add new location", TitledBorder.LEADING, TitledBorder.TOP, null, null));
//		panel_14.setBounds(23, 20, 284, 121);
//		panel_12.add(panel_14);
		
		lbLocation = new JLabel("Location :");
		lbLocation.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbLocation.setBounds(10, 39, 78, 14);
		pnAddNewLocation.add(lbLocation);
		
		
		tfCal_location = new JTextField();
		tfCal_location.addKeyListener(new KeyAdapter() {
			@Override
			public void keyPressed(KeyEvent evt) {
				if(evt.getKeyCode() == KeyEvent.VK_ENTER)
				{
					if(tfCal_location.getText().equals("")){
						JOptionPane.showMessageDialog(null, "Please enter a city");
					}
					else {
						int option = JOptionPane.showConfirmDialog(null, "Sure you want to add a new location?","Warning",JOptionPane.YES_NO_OPTION);
						if(option == JOptionPane.YES_OPTION)
						{
							Courier_Management.add_city(tfCal_location.getText());
							listLocs = Procedure.showLocations();
							listLocations.setModel(new DefaultComboBoxModel<>(listLocs));
							cbCal_S_province.setModel(new DefaultComboBoxModel<>(listLocs));
							cbCal_R_province.setModel(new DefaultComboBoxModel<>(listLocs));
							tfCal_location.setText("");
						}
					}
				}
			}
		});
		tfCal_location.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfCal_location.setColumns(10);
		tfCal_location.setBounds(98, 34, 131, 27);
		pnAddNewLocation.add(tfCal_location);
//=======
//		textField_5 = new JTextField();
//		textField_5.setColumns(10);
//		textField_5.setBounds(98, 34, 131, 27);
//		pnAddNewLocation.add(textField_5);
//>>>>>>> .r48

		btnAddNewLocation = new JButton("Add");
		btnAddNewLocation.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				if(tfCal_location.getText().equals("")){
					JOptionPane.showMessageDialog(null, "Please enter a city");
				}
				else {
					int option = JOptionPane.showConfirmDialog(null, "Sure you want to add a new location?","Warning",JOptionPane.YES_NO_OPTION);
					if(option == JOptionPane.YES_OPTION)
					{
						Courier_Management.add_city(tfCal_location.getText());
						listLocs = Procedure.showLocations();
						listLocations.setModel(new DefaultComboBoxModel<>(listLocs));
						cbCal_S_province.setModel(new DefaultComboBoxModel<>(listLocs));
						cbCal_R_province.setModel(new DefaultComboBoxModel<>(listLocs));
						cbCouRProvince.setModel(new DefaultComboBoxModel<>(listLocs));
						cbCouSProvince.setModel(new DefaultComboBoxModel<>(listLocs));
						cbCouStatus.setModel(new DefaultComboBoxModel<>(listLocs));
						tfCal_location.setText("");
					}
				}
			}
		});
		btnAddNewLocation.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAddNewLocation.setBounds(153, 72, 96, 27);
		pnAddNewLocation.add(btnAddNewLocation);
		
		pnListRoutes = new JPanel();
		pnListRoutes.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List routes", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnListRoutes.setBounds(23, 217, 422, 272);
		pnCouCalculator.add(pnListRoutes);
		pnListRoutes.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_5 = new JScrollPane();
		pnListRoutes.add(scrollPane_5, BorderLayout.CENTER);
		
		table_2 = new JTable();
		table_2.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				
			}
			@Override
			public void mousePressed(MouseEvent e) {
				if(e.getClickCount()==2 || e.getClickCount()==1){
					//int row =table_2.getSelectedRow();
					int col = table_2.getSelectedColumn();
				 if(col == 0 || col == 1 || col ==2){
						JOptionPane.showMessageDialog(null, "You don't have permition to fix that");
					}
				}
			}
		});
		table_2.setModel(Procedure.showRoads());
		scrollPane_5.setViewportView(table_2);
		
		pnListLocations = new JPanel();
		pnListLocations.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List locations", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnListLocations.setBounds(636, 20, 175, 171);
		pnCouCalculator.add(pnListLocations);
		pnListLocations.setLayout(new BorderLayout(0, 0));
		
		scrollPane_6 = new JScrollPane();
		pnListLocations.add(scrollPane_6, BorderLayout.CENTER);
		
		listLocations = new JList();
		listLocations.setFont(new Font("Tahoma", Font.PLAIN, 13));
		listLocations.setModel(new DefaultComboBoxModel<>(listLocs));
		listLocations.setEnabled(false);
		scrollPane_6.setViewportView(listLocations);
		
		
		pnCharges = new JPanel();
		pnCharges.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Charges", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnCharges.setBounds(450, 217, 387, 272);
		pnCouCalculator.add(pnCharges);
		pnCharges.setLayout(new BorderLayout(0, 0));
		
		scrollPane_7 = new JScrollPane();
		pnCharges.add(scrollPane_7, BorderLayout.CENTER);
		
		tbCalTrade = new JTable();
		tbCalTrade.addMouseListener(new MouseAdapter() {
			@Override
			public void mouseClicked(MouseEvent e) {
				
			}
			@Override
			public void mousePressed(MouseEvent e){
				if(e.getClickCount()==2 || e.getClickCount()==1){
					//int row =table_2.getSelectedRow();
					int col = tbCalTrade.getSelectedColumn();
					if(emp.getDecentralization()==1){
						if(col == 0 ){
							JOptionPane.showMessageDialog(null, "You don't have permition to fix that");
						}
					}else if(col == 0 || col == 1 || col ==2){
						JOptionPane.showMessageDialog(null, "You don't have permition to fix that");
					}
				}
			}
		});
		tbCalTrade.setFont(new Font("Tahoma", Font.PLAIN, 14));
//		tbCalTrade.setModel(new DefaultTableModel(
//			new Object[][] {
//				{"Local", "35", "5"},
//				{"Upto 500", "50", "8"},
//				{"501 - 1000", "60", "12"},
//				{"1001 - 2000", "70", "25"},
//				{"Above 2000", "90", "35"},
//			},
//			new String[] {
//				"Distance (kms)", "Rate upto 2 kg (INR)", "Additional kg (INR)"
//			}
//		));
		tbCalTrade.setModel(Procedure.showTrade());
		scrollPane_7.setViewportView(tbCalTrade);
		
		btnCalDefault = new JButton("Default");
		btnCalDefault.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				table_2.setModel(Procedure.showRoads());
				tbCalTrade.setModel(Procedure.showTrade());
			}
		});
		btnCalDefault.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnCalDefault.setBounds(575, 500, 96, 27);
		pnCouCalculator.add(btnCalDefault);
		
		btnCalEdit = new JButton("Edit");
		btnCalEdit.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent e) {
				ArrayList<String> FixDistance= new ArrayList<String>();
				ArrayList<String> FixID	= new ArrayList<String>();
				for(int i=0; i< table_2.getRowCount();i++)
				{	try{
						if(Float.parseFloat(table_2.getValueAt(i, 3).toString())<0)
						{
							throw myexception();
						}
					}catch(Exception e1){
						JOptionPane.showMessageDialog(null, "Distance must be a number");
						table_2.setModel(Procedure.showRoads());
					}
					FixDistance.add(i,table_2.getValueAt(i, 3).toString());
					FixID.add(i,  table_2.getValueAt(i, 0).toString());
				}
				try{
					for(int i=0; i<table_2.getRowCount();i++)
					{
						
						Procedure.UpdateDistance(Float.parseFloat(FixDistance.get(i)), Integer.parseInt(FixID.get(i)));
						
					}
					
					table_2.setModel(Procedure.showRoads());
				}catch(Exception ex)
				{
					JOptionPane.showMessageDialog(null, "Distance must be a number");
					table_2.setModel(Procedure.showRoads());
				}
				ArrayList<String> TradeID= new ArrayList<String>();
				ArrayList<String> Tradeprice	= new ArrayList<String>();
				ArrayList<String> Tradeaddition	= new ArrayList<String>();
				for(int i=0;i<tbCalTrade.getRowCount();i++){
					TradeID.add(i,tbCalTrade.getValueAt(i,0).toString());
					Tradeprice.add(i,tbCalTrade.getValueAt(i,1).toString());
					Tradeaddition.add(i,tbCalTrade.getValueAt(i,2).toString());
				}
				try{
				for(int i=0;i<tbCalTrade.getRowCount();i++){
					if(Float.parseFloat(Tradeprice.get(i))<0 || Float.parseFloat(Tradeaddition.get(i))<0){
						throw myexception();
					}
					Procedure.UpdateTrade(i+1, Float.parseFloat(Tradeprice.get(i)), Float.parseFloat(Tradeaddition.get(i)));
				}
				tbCalTrade.setModel(Procedure.showTrade());
				}catch(Exception ex)
				{
					JOptionPane.showMessageDialog(null, "The trade must be a number");
					tbCalTrade.setModel(Procedure.showTrade());
				}
			}

			private Exception myexception() {
				// TODO Auto-generated method stub
				return null;
			}
		});
		btnCalEdit.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnCalEdit.setBounds(695, 500, 96, 27);
		pnCouCalculator.add(btnCalEdit);
		
		JPanel pnMyInfo = new JPanel();
		tabbedPane.addTab("My Info", null, pnMyInfo, null);
		pnMyInfo.setLayout(null);
		ImageIcon iconMyInfoEmployee = new ImageIcon("images/anonymous.png");
		
		ButtonGroup groupSearch = new ButtonGroup();
		model2 = new DefaultTableModel();
		
		JPanel panelAddEmployee = new JPanel();
		tabbedPaneEmployees.addTab("Add", null, panelAddEmployee, null);
		panelAddEmployee.setLayout(null);
		
		tfAddLoginName = new JTextField();
		tfAddLoginName.setEditable(false);
		tfAddLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfAddLoginName.setColumns(10);
		tfAddLoginName.setBounds(141, 133, 188, 27);
		tfAddLoginName.setText(CreateAccount.LoginName());
		panelAddEmployee.add(tfAddLoginName);
		
		lbAddLoginName = new JLabel("Login name");
		lbAddLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddLoginName.setBounds(141, 101, 129, 21);
		panelAddEmployee.add(lbAddLoginName);
		
		lbAddName = new JLabel("Name");
		lbAddName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddName.setBounds(35, 181, 59, 21);
		panelAddEmployee.add(lbAddName);
		
		tfAddName = new JTextField();
		tfAddName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfAddName.setColumns(10);
		tfAddName.setBounds(112, 179, 216, 27);
		panelAddEmployee.add(tfAddName);
		
		lbAddAddress = new JLabel("Address");
		lbAddAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddAddress.setBounds(34, 213, 96, 21);
		panelAddEmployee.add(lbAddAddress);
		
		lbAddPhone = new JLabel("Phone");
		lbAddPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddPhone.setBounds(35, 289, 96, 21);
		panelAddEmployee.add(lbAddPhone);
		
		tfAddPhone = new JTextField();
		tfAddPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfAddPhone.setColumns(10);
		tfAddPhone.setBounds(112, 287, 216, 27);
		panelAddEmployee.add(tfAddPhone);
		
		JLabel lbAddEmpEmail = new JLabel("Email");
		lbAddEmpEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddEmpEmail.setBounds(34, 325, 96, 21);
		panelAddEmployee.add(lbAddEmpEmail);
		
		tfAddEmail = new JTextField();
		tfAddEmail.addMouseListener(new MouseAdapter() {
			public void mousePressed(MouseEvent evt)  
            {  
                if (evt.getClickCount() == 1)
                {
                    panelMailNotification.setVisible(true);
                    lblMailNotification.setVisible(true);
                }
            }
		});
		tfAddEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfAddEmail.setColumns(10);
		tfAddEmail.setBounds(111, 323, 129, 27);
		panelAddEmployee.add(tfAddEmail);
		
		final JComboBox cbAddEmpEmail = new JComboBox();
		cbAddEmpEmail.setModel(new DefaultComboBoxModel(new String[] {"@gmail.com", "@yahoo.com"}));
		cbAddEmpEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbAddEmpEmail.setBounds(250, 325, 101, 25);
		panelAddEmployee.add(cbAddEmpEmail);
		
		cbAddFunction = new JComboBox();
		if(emp.getDecentralization() != 1)
			cbAddFunction.setModel(new DefaultComboBoxModel(new String[] {"Administrator","Enquiry Department", "Working Department", "Dispatch Department"}));
		else cbAddFunction.setModel(new DefaultComboBoxModel(new String[] {"Enquiry Department", "Working Department", "Dispatch Department"}));
		cbAddFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbAddFunction.setBounds(111, 357, 188, 27);
		panelAddEmployee.add(cbAddFunction);
		
		lbAddFunction = new JLabel("Function");
		lbAddFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddFunction.setBounds(34, 359, 96, 21);
		panelAddEmployee.add(lbAddFunction);
		
		lbAddWorkingStatus = new JLabel("Working status");
		lbAddWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddWorkingStatus.setBounds(34, 393, 96, 21);
		panelAddEmployee.add(lbAddWorkingStatus);
		
		cbAddWorkingStatus = new JComboBox();
		cbAddWorkingStatus.setModel(new DefaultComboBoxModel(new String[]{"On probation","Working"}));				
		cbAddWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbAddWorkingStatus.setBounds(139, 390, 188, 27);
		panelAddEmployee.add(cbAddWorkingStatus);
		
		JSeparator separator = new JSeparator();
		separator.setBounds(405, 68, 5, 433);
		separator.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelAddEmployee.add(separator);
		
		lbAddSecurityQuestion = new JLabel("Security question");
		lbAddSecurityQuestion.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddSecurityQuestion.setBounds(429, 138, 117, 21);
		panelAddEmployee.add(lbAddSecurityQuestion);
		
		cbAddSecurityQuestion = new JComboBox();			
		cbAddSecurityQuestion.setModel(new DefaultComboBoxModel(new String[] {"What is your favourite cartoon ?", 
				"Where do you want to travel to ?","When did you have your first kiss ?",
				"Who do you love the most ?","What is the name of your primary school ?"}));
		cbAddSecurityQuestion.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbAddSecurityQuestion.setBounds(556, 135, 268, 27);
		panelAddEmployee.add(cbAddSecurityQuestion);
		
		lbAddYourAnswer = new JLabel("Your answer");
		lbAddYourAnswer.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbAddYourAnswer.setBounds(450, 170, 96, 21);
		panelAddEmployee.add(lbAddYourAnswer);
		
		tfAddYourAnswer = new JTextField();
		tfAddYourAnswer.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfAddYourAnswer.setColumns(10);
		tfAddYourAnswer.setBounds(556, 167, 216, 27);
		panelAddEmployee.add(tfAddYourAnswer);
		
		lbAddDate = new JLabel("DATE :");
		lbAddDate.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lbAddDate.setBounds(556, 11, 78, 27);
		panelAddEmployee.add(lbAddDate);
		
		JLabel labelID = new JLabel("ID :");
		labelID.setFont(new Font("Tahoma", Font.PLAIN, 15));
		labelID.setBounds(141, 82, 33, 21);
		panelAddEmployee.add(labelID);
		
		lbAddID = new JLabel(Integer.toString(CreateAccount.ID(CreateAccount.LoginName())));
		lbAddID.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lbAddID.setBounds(183, 82, 116, 21);
		panelAddEmployee.add(lbAddID);
		
		panelMailNotification = new JPanel();
		panelMailNotification.setVisible(false);
		panelMailNotification.setBorder(new LineBorder(new Color(0, 0, 0)));
		panelMailNotification.setBounds(444, 298, 363, 86);
		panelAddEmployee.add(panelMailNotification);
		panelMailNotification.setLayout(null);
		
		lblMailNotification = new JLabel("   Your email must be accurate to receive Login account !!!");
		lblMailNotification.setForeground(Color.RED);
		lblMailNotification.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblMailNotification.setBounds(10, 6, 343, 69);
		panelMailNotification.add(lblMailNotification);
	
		btnAddEmployee = new JButton("Add");
		btnAddEmployee.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if(!tfAddName.getText().trim().equals("")&&!taAddAddress.getText().trim().equals("")&&!tfAddEmail.getText().trim().equals("")&&!tfAddYourAnswer.getText().trim().equals("")){
					if(tfAddPhone.getText().matches(("(?=[^A-Za-z]+$).*[0-9].*")) && Integer.parseInt(tfAddPhone.getText()) >= 0){
						SimpleDateFormat newFormat = new SimpleDateFormat("dd/MM/yyyy");
						java.sql.Date sqlDate = new java.sql.Date(new java.util.Date().getTime());
						String loginName = CreateAccount.LoginName();
						String password = CreateAccount.randomPassword();
						String MD5password = MD5.encryptMD5(password);
						String pathAddAvatar = CreateAccount.Avatar(loginName, addAvatar,pnAddAvatar);
						String mail = tfAddEmail.getText()+String.valueOf(cbAddEmail.getSelectedItem());
						int indexFunc = -1;
						if(emp.getDecentralization() == 1)
							indexFunc = cbAddFunction.getSelectedIndex()+2;
						else indexFunc = cbAddFunction.getSelectedIndex()+1;
						int check = Procedure.AddEmpInfo(CreateAccount.ID(CreateAccount.LoginName()),tfAddName.getText(), taAddAddress.getText(), Integer.parseInt(tfAddPhone.getText()), mail , pathAddAvatar ,cbAddWorkingStatus.getSelectedIndex(), indexFunc, loginName, MD5password ,cbAddSecurityQuestion.getSelectedIndex(), tfAddYourAnswer.getText(),sqlDate);
						if(check==1){
//							JDialog dialog = new JDialog();
							ThreadWaiting thread = new ThreadWaiting();
//							thread.start();
							thread.show();
							boolean flgSuccess;
							flgSuccess = Mail.send(mail,loginName,password);
							Procedure.IncreaseID();
							tfAddLoginName.setText(CreateAccount.LoginName());
							lbAddID.setText(Integer.toString(CreateAccount.ID(CreateAccount.LoginName())));
							tfAddName.setText("");
							tfAddPhone.setText("");
							taAddAddress.setText("");
							tfAddEmail.setText("");	
							tfAddYourAnswer.setText(""); 
							lblMailNotification.setVisible(false);
							panelMailNotification.setVisible(false);
							ImageIcon anonymous = new ImageIcon("images/anonymous.png");
							btnAddAvatar.setIcon(anonymous);
							Attendance_Management.addEmpInAttendance(loginName);
							Attendance_Management.getAttendance(tableAttendance,emp.getLoginName(),new Date());
							modelTable = new DefaultTableModel();
							Procedure.List_Emp(modelTable, tbList, 1, "",emp.getLoginName(), 0, 0);
//							dialog.setVisible(false);
//							dialog.dispose();
//							thread.interrupt();
							thread.hide();
							if(flgSuccess == true)
							{
								JOptionPane.showMessageDialog(null, "Added Successfully!");
							}
							else
								{
									JOptionPane.showMessageDialog(null,"Lost connection!", "Warning",JOptionPane.WARNING_MESSAGE);
									
									Procedure.AddConn(loginName);
									model3 = new DefaultTableModel();
									Procedure.List_notSent(model3, tableNotSent,0,tfSearchNotSentLogin,tfSearchNotSentDate);
								}
								modelTable = new DefaultTableModel(){					
									public boolean isCellEditable(int row, int col){
										return false;
									}				
								};
								cbFindFunction.setSelectedIndex(5);
								cbFindWorkingStatus.setSelectedIndex(4);
								tbList.changeSelection(0, 0, false, false);
								Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tbList.getValueAt(0, 0).toString(),btnInfoAvatar );
						}else{
							JOptionPane.showMessageDialog(null, "Can not add!");
							panelMailNotification.setVisible(false);
						}
					}else{
						JOptionPane.showMessageDialog(null, "Phone must contain numbers only!");
					}
				}else{
					JOptionPane.showMessageDialog(null, "You must fill in all blanks !");
				}
			}
		});
		btnAddEmployee.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAddEmployee.setBounds(556, 235, 89, 23);
		panelAddEmployee.add(btnAddEmployee);
		
		pnAddAvatar = new JPanel();
		pnAddAvatar.setBounds(35, 80, 80, 80);
		panelAddEmployee.add(pnAddAvatar);
		pnAddAvatar.setLayout(new BorderLayout(0, 0));
		
		btnAddAvatar = new JButton("");
		pnAddAvatar.add(btnAddAvatar, BorderLayout.CENTER);
		btnAddAvatar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				addAvatar = Employee.changeAvatar(btnAddAvatar);
			}
		});
		btnAddAvatar.setToolTipText("Change avatar");
		btnAddAvatar.setIcon(iconAddEmployee);
		lbAddCurrentTime = new JLabel("");
		lbAddCurrentTime.setText(timeStamp);
		lbAddCurrentTime.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lbAddCurrentTime.setBounds(622, 11, 117, 27);
		panelAddEmployee.add(lbAddCurrentTime);
		
		JScrollPane scrollPane_11 = new JScrollPane();
		scrollPane_11.setBounds(112, 213, 216, 65);
		panelAddEmployee.add(scrollPane_11);
		
		taAddAddress = new JTextArea();
		scrollPane_11.setViewportView(taAddAddress);
		taAddAddress.setTabSize(4);
		taAddAddress.setRows(4);
		taAddAddress.setLineWrap(true);
		taAddAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));

		pnAttendance = new JPanel();
		tabbedPaneEmployees.addTab("Attendance", null, pnAttendance, null);
		pnAttendance.setLayout(null);
		
		pnAttSearch = new JPanel();
		pnAttSearch.setLayout(null);
		pnAttSearch.setBorder(new TitledBorder(null, "Find", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnAttSearch.setBounds(10, 11, 616, 119);
		pnAttendance.add(pnAttSearch);
		
		lblAttSearchLoginname = new JLabel("Login name");
		lblAttSearchLoginname.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblAttSearchLoginname.setBounds(29, 24, 102, 16);
		pnAttSearch.add(lblAttSearchLoginname);
		
		tfSearchAttendanceLoginname = new JTextField();
		tfSearchAttendanceLoginname.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfSearchAttendanceLoginname.setColumns(10);
		tfSearchAttendanceLoginname.setBounds(134, 21, 139, 22);
		pnAttSearch.add(tfSearchAttendanceLoginname);
		
		lblAttSearchFunction = new JLabel("Function");
		lblAttSearchFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblAttSearchFunction.setBounds(29, 50, 96, 21);
		pnAttSearch.add(lblAttSearchFunction);
		
		cbSearchAttendanceFunction = new JComboBox();
		cbSearchAttendanceFunction.setModel(new DefaultComboBoxModel(new String[] {"President", "Administrator", "Enquiry Department", "Working Department", "Dispatch Department","All"}));
		cbSearchAttendanceFunction.setSelectedIndex(5);
		cbSearchAttendanceFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbSearchAttendanceFunction.setBounds(134, 47, 188, 27);
		pnAttSearch.add(cbSearchAttendanceFunction);
		
		btnAttSearch = new JButton("Search");
		btnAttSearch.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				String date = Attendance_Management.findAttendance(tableAttendance,emp.getLoginName(),tfSearchAttendanceLoginname.getText(),cbSearchAttendanceFunction.getSelectedIndex(),tfSearchAttendanceDate,cbAttSearchAbsence.getSelectedIndex());
				lblInfoDateAttendance.setText(date);
			}
			});
		btnAttSearch.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAttSearch.setBounds(498, 83, 96, 27);
		pnAttSearch.add(btnAttSearch);
		
		lblAttSearchAbsence = new JLabel("Absence");
		lblAttSearchAbsence.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblAttSearchAbsence.setBounds(339, 54, 61, 16);
		pnAttSearch.add(lblAttSearchAbsence);

		lblAttSearchDate = new JLabel("Date");
		lblAttSearchDate.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lblAttSearchDate.setBounds(339, 21, 61, 16);
		pnAttSearch.add(lblAttSearchDate);
		
		cbAttSearchAbsence = new JComboBox();
		cbAttSearchAbsence.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbAttSearchAbsence.setModel(new DefaultComboBoxModel(new String[] {"None", "Yes", "No"}));
		cbAttSearchAbsence.setSelectedIndex(0);
		cbAttSearchAbsence.setBounds(400, 50, 112, 27);
		pnAttSearch.add(cbAttSearchAbsence);
		
		tfSearchAttendanceDate = new JXDatePicker();
		tfSearchAttendanceDate.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfSearchAttendanceDate.getEditor().setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfSearchAttendanceDate.setBounds(400, 20, 143, 27);
		pnAttSearch.add(tfSearchAttendanceDate);
		tfSearchAttendanceDate.setDate(null);
		tfSearchAttendanceDate.setFormats(new SimpleDateFormat("dd-MM-yyyy"));
		
		btnAttShowAll = new JButton("Show all");
		btnAttShowAll.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				
				Attendance_Management.getAllAttendance(tableAttendance,emp.getLoginName());			
				cbSearchAttendanceFunction.setSelectedIndex(5);
				cbAttSearchAbsence.setSelectedIndex(0);
			}
		});
		btnAttShowAll.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAttShowAll.setBounds(388, 83, 84, 27);
		pnAttSearch.add(btnAttShowAll);
		
		pnAttList = new JPanel();
		pnAttList.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnAttList.setBounds(34, 137, 793, 309);
		pnAttendance.add(pnAttList);
		pnAttList.setLayout(new BorderLayout(0, 0));
		
		JScrollPane scrollPane_1 = new JScrollPane();		
		pnAttList.add(scrollPane_1, BorderLayout.CENTER);
		
		tableAttendance = new JTable();
		tableAttendance.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
		tableAttendance.setRowSelectionAllowed(true);
		tableAttendance.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				if(e.getClickCount() == 1)
					for(int i=0;i<tbList.getRowCount();i++){
						if(((String)tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0)).equals((String)tbList.getValueAt(i, 1))){
							tbList.changeSelection(i, 1, false, false);
						}
					}
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0).toString(),btnInfoAvatar );
				int col = tableAttendance.getSelectedColumn();
				if(e.getClickCount() == 2)
					if(col == 0 || col == 1 || col == 2)
					{
						JOptionPane.showMessageDialog(null, "You just have permission to fix columns :\nabsence, on leave until day, note");
					}
			}
			@Override
			public void mouseClicked(MouseEvent evt) {
				if(evt.getClickCount() == 1)
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tbList.getValueAt(tableAttendance.getSelectedRow(), 0).toString(),btnInfoAvatar );
			}
		});
		tableAttendance.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null, null},
			},
			new String[] {
				"ID", "Login name", "Function", "Absence", "Pause", "To day", "Note"
			}
		));
		scrollPane_1.setViewportView(tableAttendance);	
		tableAttendance.addKeyListener(new KeyListener() {
			
			@Override
			public void keyTyped(KeyEvent e) {
				// TODO Auto-generated method stub				
			}
			
			@Override
			public void keyReleased(KeyEvent e) {
				// TODO Auto-generated method stub		
				for(int i=0;i<tbList.getRowCount();i++){
					if(((String)tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0)).equals((String)tbList.getValueAt(i, 1))){
						tbList.changeSelection(i, 1, false, false);
					}
				}
				if(e.getKeyCode()==KeyEvent.VK_UP){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0).toString(),btnInfoAvatar );
				}
				if(e.getKeyCode()==KeyEvent.VK_DOWN){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0).toString(),btnInfoAvatar );
				}
			}
			
			@Override
			public void keyPressed(KeyEvent e) {
				// TODO Auto-generated method stub	
				for(int i=0;i<tbList.getRowCount();i++){
					if(((String)tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0)).equals((String)tbList.getValueAt(i, 1))){
						tbList.changeSelection(i, 1, false, false);
					}
				}
				if(e.getKeyCode()==KeyEvent.VK_UP){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0).toString(),btnInfoAvatar );
				}
				if(e.getKeyCode()==KeyEvent.VK_DOWN){
					Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail,cbInfoFunction,cbFindFunction, tableAttendance.getValueAt(tableAttendance.getSelectedRow(), 0).toString(),btnInfoAvatar );
				}
			}
		
		});
		
		lblNow = new JLabel("NOW :");
		lblNow.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblNow.setBounds(637, 17, 78, 27);
		pnAttendance.add(lblNow);
		
		lblDate = new JLabel("DATE :");
		lblDate.setFont(new Font("Tahoma", Font.PLAIN, 18));
		lblDate.setBounds(637, 50, 78, 27);
		pnAttendance.add(lblDate);
		
		btnAttSave = new JButton("Save");
		btnAttSave.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {			
				int option = JOptionPane.showConfirmDialog(null, "Sure you want to save this attendance sheet?","Message",JOptionPane.YES_NO_OPTION);
				if(option == JOptionPane.YES_OPTION)
				{
					Procedure.updateAttendance(tableAttendance,lblInfoDateAttendance);
					modelTable = new DefaultTableModel();
					Procedure.List_Emp(modelTable, tbList, 1, "",emp.getLoginName(), 0, 0);
				}
			}
		});
		btnAttSave.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAttSave.setBounds(676, 469, 84, 27);
		pnAttendance.add(btnAttSave);
		
		btnAttDefault = new JButton("Default");
		btnAttDefault.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				Attendance_Management.getAttendance(tableAttendance, emp.getLoginName(),new Date());
			}
		});
		btnAttDefault.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnAttDefault.setBounds(553, 469, 94, 27);
		pnAttendance.add(btnAttDefault);
		
				
				JLabel lblCurrentTime = new JLabel("");
				lblCurrentTime.setText(timeStamp);
				lblCurrentTime.setFont(new Font("Tahoma", Font.PLAIN, 16));
				lblCurrentTime.setBounds(703, 11, 100, 38);
				pnAttendance.add(lblCurrentTime);
				
				lblInfoDateAttendance = new JLabel("");
				lblInfoDateAttendance.setText(timeStamp);
				lblInfoDateAttendance.setFont(new Font("Tahoma", Font.PLAIN, 16));
				lblInfoDateAttendance.setBounds(703, 50, 100, 27);
				pnAttendance.add(lblInfoDateAttendance);
				
				panelConnection = new JPanel();
				tabbedPaneEmployees.addTab("Connection", null, panelConnection, null);
				panelConnection.setLayout(null);
				
				pnConnList = new JPanel();
				pnConnList.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "List", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
				pnConnList.setBounds(37, 146, 616, 363);
				panelConnection.add(pnConnList);
				pnConnList.setLayout(new BorderLayout(0, 0));
				
				scrollPane_8 = new JScrollPane();
				pnConnList.add(scrollPane_8, BorderLayout.CENTER);
				
				tableNotSent = new JTable();
				tableNotSent.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
				tableNotSent.setRowSelectionAllowed(true);
				tableNotSent.setModel(new DefaultTableModel(
					new Object[][] {
						{null, null, null, null, null},
					},
					new String[] {
						"ID", "Login name", "Date created", "Mail", "Send"
					}
				));
				scrollPane_8.setViewportView(tableNotSent);
				model3 = new DefaultTableModel(){
					public boolean isCellEditable(int row,int col){
						if(col==4){
							return true;
						}
						return false;
					}
				};
				
				tableNotSent.addMouseListener(new MouseAdapter() {
					public void mousePressed(MouseEvent e){
						if(e.getClickCount() == 1){
							for(int i=0;i<tbList.getRowCount();i++){
								if(((String)tableNotSent.getValueAt(tableNotSent.getSelectedRow(), 1)).equals((String)tbList.getValueAt(i, 1))){
									tbList.changeSelection(i, 1, false, false);
								}
							}
							Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, (String)tableNotSent.getValueAt(tableNotSent.getSelectedRow(), 1),btnInfoAvatar );
						}
						if(e.getClickCount()==2){
							int col = tableNotSent.getSelectedColumn();
							if(col==0||col==1){
								JOptionPane.showMessageDialog(null,"You are not allowed to edit ID and Login Name " );
							}	
							if(col==2||col==3){
								int option = JOptionPane.showConfirmDialog(null,"Do you want to edit info","Confirm",JOptionPane.YES_NO_OPTION);
								if(option==JOptionPane.YES_OPTION){
									tabbedPaneEmployees.setSelectedIndex(0);
								}
										
							}
						}
					}
				});
				tableNotSent.addKeyListener(new KeyListener() {
					
					@Override
					public void keyTyped(KeyEvent k) {
						// TODO Auto-generated method stub
						
					}
					
					@Override
					public void keyReleased(KeyEvent k) {
						// TODO Auto-generated method stub
						if(k.getKeyCode()==KeyEvent.VK_UP){
							Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, (String)model3.getValueAt(tableNotSent.getSelectedRow(), 1),btnInfoAvatar );
						}
						if(k.getKeyCode()==KeyEvent.VK_DOWN){
							Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, (String)model3.getValueAt(tableNotSent.getSelectedRow(), 1),btnInfoAvatar );
						}
					}
					
					@Override
					public void keyPressed(KeyEvent k) {
						// TODO Auto-generated method stub
						if(k.getKeyCode()==KeyEvent.VK_UP){
							Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, (String)model3.getValueAt(tableNotSent.getSelectedRow(), 1),btnInfoAvatar );
						}
						if(k.getKeyCode()==KeyEvent.VK_DOWN){
							Procedure.showEmpDetail(lbInfoIndexID,tfInfoLoginName,tfInfoDateCreated,tfInfoName, taInfoAddress,tfInfoPhone,tfInfoEmail,cbInfoEmail, cbInfoFunction,cbInfoWorkingStatus, (String)model3.getValueAt(tableNotSent.getSelectedRow(), 1),btnInfoAvatar );
						}
					}
				});
				//Connection_Mail.List_notSent(model3, tableNotSent,0,tfSearchNotSentLogin,tfSearchNotSentDate);
				btnDefaultConn = new JButton("Default");
				btnDefaultConn.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						for(int i=0;i<tableNotSent.getRowCount();i++){
							model3.setValueAt(false,i ,4);
						}
					}
				});
				btnDefaultConn.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnDefaultConn.setBounds(691, 232, 115, 27);
				panelConnection.add(btnDefaultConn);
				
				btnSelectAllConn = new JButton("Select all");
				btnSelectAllConn.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						for(int i=0;i<tableNotSent.getRowCount();i++){
							model3.setValueAt(true,i ,4);
						}
					}
				});
				btnSelectAllConn.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnSelectAllConn.setBounds(691, 270, 115, 27);
				panelConnection.add(btnSelectAllConn);
				
				btnSendMail = new JButton("Send");
				btnSendMail.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
//						JDialog dialog = new JDialog();
						ThreadWaiting thread = new ThreadWaiting();
						thread.show();
						boolean sendSucc = false;
						for(int i=0;i<tableNotSent.getRowCount();i++){
							
							if(tableNotSent.getValueAt(i, 4).equals(true)){								
								String loginname = (String)tableNotSent.getValueAt(i, 1);								
								String mail = (String)tableNotSent.getValueAt(i, 2);
								String pass = CreateAccount.randomPassword();
								String MD5pass = MD5.encryptMD5(pass);
								
								sendSucc = Mail.send(mail, loginname,pass);							
								if(sendSucc == true){									
									Connection_Mail.Sent(loginname,MD5pass);
								}else{
									thread.hide();
//									dialog.dispose();
//									thread.interrupt();
									JOptionPane.showMessageDialog(null, "Lost Connection!");
									break;
								}
							}
						}
						model3 = new DefaultTableModel();
						Connection_Mail.List_notSent(model3, tableNotSent, 0, tfSearchNotSentLogin, tfSearchNotSentDate);
//						dialog.setVisible(false);
//						dialog.dispose();
//						thread.interrupt();
						thread.hide();
						if(sendSucc == true)
							JOptionPane.showMessageDialog(null, "Mail Sent!");
					}
					
				});
				btnSendMail.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnSendMail.setBounds(691, 309, 115, 27);
				panelConnection.add(btnSendMail);
				
				btnEmployeeDetail = new JButton("Detail");
				btnEmployeeDetail.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						tabbedPaneEmployees.setSelectedIndex(0);
					}
				});
				btnEmployeeDetail.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnEmployeeDetail.setBounds(691, 194, 115, 27);
				panelConnection.add(btnEmployeeDetail);

				btnDeleteConn = new JButton("Delete");
				btnDeleteConn.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						if(tableNotSent.getSelectedRow()>-1){														
							int option = JOptionPane.showConfirmDialog(null, "Sure you want to delete this employee ?", "Confirm Question", JOptionPane.YES_NO_OPTION);
							if(option==JOptionPane.YES_OPTION){							
								Connection_Mail.DeleteConn((String)model3.getValueAt(tableNotSent.getSelectedRow(), 1));
								model3.removeRow(tableNotSent.getSelectedRow());									
															
								JOptionPane.showMessageDialog(null, "Deleted!");
							}
						}else{
							JOptionPane.showMessageDialog(null, "Choose the row you want to delete in table please!");
						}
					}
				});
				btnDeleteConn.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnDeleteConn.setBounds(691, 348, 115, 27);
				panelConnection.add(btnDeleteConn);
				
				pnConnSearch = new JPanel();
				pnConnSearch.setLayout(null);
				pnConnSearch.setBorder(new TitledBorder(new EtchedBorder(EtchedBorder.LOWERED, null, null), "Search", TitledBorder.LEADING, TitledBorder.TOP, null, null));
				pnConnSearch.setBounds(37, 16, 440, 119);
				panelConnection.add(pnConnSearch);
				
				lbConnLogin = new JLabel("Login name");
				lbConnLogin.setFont(new Font("Tahoma", Font.PLAIN, 13));
				lbConnLogin.setBounds(29, 24, 102, 16);
				pnConnSearch.add(lbConnLogin);
				
				tfSearchNotSentLogin = new JTextField();	
				tfSearchNotSentLogin.setFont(new Font("Tahoma", Font.PLAIN, 13));
				tfSearchNotSentLogin.setColumns(10);
				tfSearchNotSentLogin.setBounds(134, 21, 152, 22);
				pnConnSearch.add(tfSearchNotSentLogin);
				
				tfSearchNotSentDate = new JXDatePicker();	
				tfSearchNotSentDate.setFont(new Font("Tahoma", Font.PLAIN, 13));
				tfSearchNotSentDate.getEditor().setFont(new Font("Tahoma", Font.PLAIN, 13));
				tfSearchNotSentDate.setBounds(134, 69, 152, 24);
				tfSearchNotSentDate.setDate(null);
				tfSearchNotSentDate.setFormats(new SimpleDateFormat("dd-MM-yyyy"));
				pnConnSearch.add(tfSearchNotSentDate);
				
				btnConnSearch = new JButton("Search");
				btnConnSearch.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnConnSearch.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent arg0) {
						model3 = new DefaultTableModel();
						if(tfSearchNotSentLogin.getText().trim().equals("")&&tfSearchNotSentDate.getDate()==null){							
							Connection_Mail.List_notSent(model3, tableNotSent, 0, tfSearchNotSentLogin, tfSearchNotSentDate);
						}
						if(!tfSearchNotSentLogin.getText().trim().equals("")&&tfSearchNotSentDate.getDate()==null){							
							Connection_Mail.List_notSent(model3, tableNotSent, 1, tfSearchNotSentLogin, tfSearchNotSentDate);
						}
						if(tfSearchNotSentLogin.getText().trim().equals("")&&tfSearchNotSentDate.getDate()!=null){							
							Connection_Mail.List_notSent(model3, tableNotSent, 2, tfSearchNotSentLogin, tfSearchNotSentDate);
						}
						if(!tfSearchNotSentLogin.getText().trim().equals("")&&tfSearchNotSentDate.getDate()!=null){							
							Connection_Mail.List_notSent(model3, tableNotSent, 3, tfSearchNotSentLogin, tfSearchNotSentDate);
						}
							
					}
				});
				
				btnConnSearch.setBounds(321, 20, 91, 27);
				pnConnSearch.add(btnConnSearch);
				
				btnConnShowAll = new JButton("Show all");
				btnConnShowAll.setFont(new Font("Tahoma", Font.PLAIN, 13));
				btnConnShowAll.addActionListener(new ActionListener() {
					public void actionPerformed(ActionEvent e) {
						model3 = new DefaultTableModel();								
						Connection_Mail.List_notSent(model3, tableNotSent,0,tfSearchNotSentLogin,tfSearchNotSentDate);						
					}
				});
				btnConnShowAll.setBounds(321, 68, 91, 27);
				pnConnSearch.add(btnConnShowAll);
				
				lbConnDate = new JLabel("Date");
				lbConnDate.setFont(new Font("Tahoma", Font.PLAIN, 13));
				lbConnDate.setBounds(29, 74, 73, 14);
				pnConnSearch.add(lbConnDate);
//		
		JLabel lbID = new JLabel("ID :");
		lbID.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lbID.setBounds(150, 59, 33, 21);
		pnMyInfo.add(lbID);
		
		lbMyInfoID = new JLabel("");
		lbMyInfoID.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lbMyInfoID.setBounds(182, 59, 146, 21);
		pnMyInfo.add(lbMyInfoID);
		
		lbMyInfoLoginName = new JLabel("Login name");
		lbMyInfoLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoLoginName.setBounds(150, 87, 129, 21);
		pnMyInfo.add(lbMyInfoLoginName);
		
		tfMyInfoLoginName = new JTextField();
		tfMyInfoLoginName.setEditable(false);
		tfMyInfoLoginName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfMyInfoLoginName.setColumns(10);
		tfMyInfoLoginName.setBounds(151, 112, 188, 27);
		pnMyInfo.add(tfMyInfoLoginName);
		
		tfMyInfoDateCreated = new JTextField();
		tfMyInfoDateCreated.setEditable(false);
		tfMyInfoDateCreated.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfMyInfoDateCreated.setColumns(10);
		tfMyInfoDateCreated.setBounds(141, 156, 200, 27);
		pnMyInfo.add(tfMyInfoDateCreated);
		
		lbMyInfoDateCreated = new JLabel("Date created");
		lbMyInfoDateCreated.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoDateCreated.setBounds(48, 158, 96, 21);
		pnMyInfo.add(lbMyInfoDateCreated);
		
		lbMyInfoName = new JLabel("Name");
		lbMyInfoName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoName.setBounds(48, 194, 96, 21);
		pnMyInfo.add(lbMyInfoName);
		
		tfMyInfoName = new JTextField();
		tfMyInfoName.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfMyInfoName.setColumns(10);
		tfMyInfoName.setBounds(125, 192, 216, 27);
		pnMyInfo.add(tfMyInfoName);
		
		lbMyInfoAddress = new JLabel("Address");
		lbMyInfoAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoAddress.setBounds(47, 238, 96, 21);
		pnMyInfo.add(lbMyInfoAddress);
		
		taMyInfoAddress = new JTextArea();
		taMyInfoAddress.setTabSize(4);
		taMyInfoAddress.setRows(4);
		taMyInfoAddress.setLineWrap(true);
		taMyInfoAddress.setFont(new Font("Tahoma", Font.PLAIN, 13));
		taMyInfoAddress.setBorder(new LineBorder(new Color(0, 0, 0)));
		taMyInfoAddress.setBounds(125, 238, 216, 65);
		pnMyInfo.add(taMyInfoAddress);
		
		lbMyInfoPhone = new JLabel("Phone");
		lbMyInfoPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoPhone.setBounds(46, 316, 96, 21);
		pnMyInfo.add(lbMyInfoPhone);
		
		tfMyInfoPhone = new JTextField();
		tfMyInfoPhone.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfMyInfoPhone.setColumns(10);
		tfMyInfoPhone.setBounds(123, 314, 216, 27);
		pnMyInfo.add(tfMyInfoPhone);
		
		lbMyInfoEmail = new JLabel("Email");
		lbMyInfoEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoEmail.setBounds(46, 350, 96, 21);
		pnMyInfo.add(lbMyInfoEmail);
		
		tfMyInfoNameEmail = new JTextField();
		tfMyInfoNameEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		tfMyInfoNameEmail.setColumns(10);
		tfMyInfoNameEmail.setBounds(123, 348, 129, 27);
		pnMyInfo.add(tfMyInfoNameEmail);
		
		cbMyInfoEmail = new JComboBox();
		cbMyInfoEmail.setModel(new DefaultComboBoxModel(new String[]{"@gmail.com","@yahoo.com"}));
		cbMyInfoEmail.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbMyInfoEmail.setBounds(262, 350, 101, 25);
		pnMyInfo.add(cbMyInfoEmail);
	
		cbMyInfoFunction = new JComboBox();
		cbMyInfoFunction.setModel(new DefaultComboBoxModel(new String[] {"President", "Administrator", "Enquiry Department", "Working Department", "Dispatch Department"}));
		cbMyInfoFunction.setEnabled(false);
		cbMyInfoFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbMyInfoFunction.setBounds(123, 382, 188, 27);
		pnMyInfo.add(cbMyInfoFunction);
		
		lbMyInfoFunction = new JLabel("Function");
		lbMyInfoFunction.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoFunction.setBounds(46, 384, 96, 21);
		pnMyInfo.add(lbMyInfoFunction);
		
		lbMyInfoWorkingStatus = new JLabel("Working status");
		lbMyInfoWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoWorkingStatus.setBounds(46, 423, 96, 21);
		pnMyInfo.add(lbMyInfoWorkingStatus);
		
		cbMyInfoWorkingStatus = new JComboBox();
		cbMyInfoWorkingStatus.setModel(new DefaultComboBoxModel(new String[] {"On probation", "Working", "On leave of absence", "Quit"}));
		cbMyInfoWorkingStatus.setEnabled(false);
		cbMyInfoWorkingStatus.setFont(new Font("Tahoma", Font.PLAIN, 13));
		cbMyInfoWorkingStatus.setBounds(151, 420, 188, 27);
		pnMyInfo.add(cbMyInfoWorkingStatus);
		
		pnChangeMyPassword = new JPanel();
		pnChangeMyPassword.setBorder(new TitledBorder(null, "Change my password", TitledBorder.LEADING, TitledBorder.TOP, new Font("Tahoma", Font.PLAIN, 17), null));
		pnChangeMyPassword.setBounds(426, 58, 361, 190);
		pnMyInfo.add(pnChangeMyPassword);
		pnChangeMyPassword.setLayout(null);
		
		lbMyInfoCurrentPassword = new JLabel("Current password");
		lbMyInfoCurrentPassword.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoCurrentPassword.setBounds(20, 33, 122, 21);
		pnChangeMyPassword.add(lbMyInfoCurrentPassword);
		
		tfMyInfoCurrentPassword = new JPasswordField();
		tfMyInfoCurrentPassword.setBounds(174, 31, 164, 27);
		pnChangeMyPassword.add(tfMyInfoCurrentPassword);
		
		tfMyInfoNewPassword = new JPasswordField();
		tfMyInfoNewPassword.setBounds(174, 65, 164, 27);
		pnChangeMyPassword.add(tfMyInfoNewPassword);
		
		lbMyInfoNewPassword = new JLabel("New password");
		lbMyInfoNewPassword.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoNewPassword.setBounds(20, 67, 122, 21);
		pnChangeMyPassword.add(lbMyInfoNewPassword);
		
		tfMyInfoConfirmNewPassword = new JPasswordField();
		tfMyInfoConfirmNewPassword.setBounds(174, 99, 164, 27);
		pnChangeMyPassword.add(tfMyInfoConfirmNewPassword);
		
		lbMyInfoConfirmNewPassword = new JLabel("Confirm new password");
		lbMyInfoConfirmNewPassword.setFont(new Font("Tahoma", Font.PLAIN, 13));
		lbMyInfoConfirmNewPassword.setBounds(20, 101, 144, 21);
		pnChangeMyPassword.add(lbMyInfoConfirmNewPassword);
		
		btnMyInfoChange = new JButton("Change");
		btnMyInfoChange.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				if(String.valueOf(tfMyInfoNewPassword.getPassword()).length() >= 6)
				emp.changeMyPassword(String.valueOf(tfMyInfoCurrentPassword.getPassword()), String.valueOf(tfMyInfoNewPassword.getPassword()),String.valueOf(tfMyInfoConfirmNewPassword.getPassword()),lbWarningChangePassword);
				else
					JOptionPane.showMessageDialog(null, "Your new password must have more than 6 characters!","Warning",JOptionPane.WARNING_MESSAGE);
			}
		});
		btnMyInfoChange.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnMyInfoChange.setBounds(122, 156, 91, 23);
		pnChangeMyPassword.add(btnMyInfoChange);
		
		lbWarningChangePassword = new JLabel("");
		lbWarningChangePassword.setBounds(20, 133, 318, 21);
		pnChangeMyPassword.add(lbWarningChangePassword);
		lbWarningChangePassword.setForeground(Color.RED);
		lbWarningChangePassword.setFont(new Font("Tahoma", Font.PLAIN, 13));
		
		btnMyInfoDefault = new JButton("Default");
		btnMyInfoDefault.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				Procedure.showEmpDetail(lbMyInfoID, tfMyInfoLoginName, tfMyInfoDateCreated, tfMyInfoName,taMyInfoAddress, tfMyInfoPhone, tfMyInfoNameEmail, cbMyInfoEmail, cbMyInfoWorkingStatus, cbMyInfoWorkingStatus, tfMyInfoLoginName.getText(),btnInfoAvatar);
			}
		});
		btnMyInfoDefault.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnMyInfoDefault.setBounds(92, 474, 91, 23);
		pnMyInfo.add(btnMyInfoDefault);
		
		btnMyInfoEdit = new JButton("Edit");
		btnMyInfoEdit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				JOptionPane.showConfirmDialog(null,"Sure you want to edit?","Warning",JOptionPane.YES_NO_OPTION);
				int option = JOptionPane.YES_NO_OPTION;
				if(option == JOptionPane.YES_OPTION)
				{
					if(tfMyInfoPhone.getText().matches("[0-9]") && Integer.parseInt(tfMyInfoPhone.getText()) >=0)
					{
						emp.setName(tfMyInfoName.getText());
						emp.setAddress(taMyInfoAddress.getText());
						emp.setPhone(Integer.parseInt(tfMyInfoPhone.getText()));
						emp.setMail(tfMyInfoNameEmail.getText()+cbMyInfoEmail.getSelectedItem().toString());
						emp.setImage(CreateAccount.Avatar(emp.getLoginName(), myAvatar,pnMyInfoAvatar));
						Procedure.UpdateInfo(emp.getLoginName(), emp.getName(), emp.getAddress(), emp.getPhone(), emp.getMail(),emp.getImage(),emp.getDecentralization(), emp.getStatus());
					} else JOptionPane.showMessageDialog(null, "Phone must contain numbers only!");
				}
				else
				{
					//TODO
				}
			}
		});
		btnMyInfoEdit.setFont(new Font("Tahoma", Font.PLAIN, 13));
		btnMyInfoEdit.setBounds(248, 475, 91, 23);
		pnMyInfo.add(btnMyInfoEdit);
		
		pnMyInfoAvatar = new JPanel();
		pnMyInfoAvatar.setBounds(48, 59, 80, 80);
		pnMyInfo.add(pnMyInfoAvatar);
		pnMyInfoAvatar.setLayout(new BorderLayout(0, 0));
		
		btnMyInfoAvatar = new JButton("");
		pnMyInfoAvatar.add(btnMyInfoAvatar, BorderLayout.CENTER);
		btnMyInfoAvatar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				myAvatar = Employee.changeAvatar(btnMyInfoAvatar);
			}
		});
		btnMyInfoAvatar.setToolTipText("Change avatar");
		
		JSeparator separator_1 = new JSeparator();
		separator_1.setBorder(new LineBorder(new Color(0, 0, 0)));
		separator_1.setBounds(393, 51, 5, 433);
		pnMyInfo.add(separator_1);
		
		JMenuBar menuBar = new JMenuBar();
		frmCourierManagementSystem.setJMenuBar(menuBar);
		
		mnSystem = new JMenu("System");
		menuBar.add(mnSystem);
		
		itemLogout = new JMenuItem("Logout");
		itemLogout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				System.gc();
				Main.frmCourierManagementSystem.dispose();			
				Login.lbWarning.setVisible(false);
				Login.frLogin.setVisible(true);
			}
		});
		mnSystem.add(itemLogout);
		
		itemExit = new JMenuItem("Exit");
		itemExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
		mnSystem.add(itemExit);
		mnLanguage = new JMenu("Language");
		menuBar.add(mnLanguage);
		
		radioEnglish = new JRadioButtonMenuItem("English");
		ImageIcon iconUK = new ImageIcon("images/UK.png");
		radioEnglish.setIcon(iconUK);
		radioEnglish.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				International.locale = new Locale("en","UK");
				International.setLanguageMain(International.locale);
				if(tempCheckCouRadio == 1)
					rdbtnCouUpdate.setSelected(true);
				if(tempCheckCouRadio == 2)
					rdbtnCouNew.setSelected(true);
				if(tempCheckCouRadio == 3)
					rdbtnCouDelete.setSelected(true);
			}
		});
		buttonGroup.add(radioEnglish);
		mnLanguage.add(radioEnglish);
		
		radioVietnamese = new JRadioButtonMenuItem("Vietnamese");
		ImageIcon iconVN = new ImageIcon("images/VN.png");
		radioVietnamese.setIcon(iconVN);
		radioVietnamese.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent evt) {
				International.locale = new Locale("vi","VN");
				International.setLanguageMain(International.locale);
				if(tempCheckCouRadio == 1)
					rdbtnCouUpdate.setSelected(true);
				if(tempCheckCouRadio == 2)
					rdbtnCouNew.setSelected(true);
				if(tempCheckCouRadio == 3)
					rdbtnCouDelete.setSelected(true);
			}
		});
		buttonGroup.add(radioVietnamese);
		mnLanguage.add(radioVietnamese);
		
		mnHelp = new JMenu("Help");
		menuBar.add(mnHelp);
		
		itemAbout = new JMenuItem("About...");
		itemAbout.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				new About();
			}
		});
		
		itemHelp = new JMenuItem("Help");
		itemHelp.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				try
				{
				File helpFile = new File("help/help.chm");
				Desktop dk = Desktop.getDesktop();
				dk.open(helpFile);
				} catch(Exception ex) {}
			}
		});
		mnHelp.add(itemHelp);
		mnHelp.add(itemAbout);

		//check(3);
		Courier_Management.get_cou_has_not_done(tbCouShow);
		tfFindDate.setDate(null);
		rdbtnCouNew.setSelected(true);
		
		JPanel panel_3 = new JPanel();
		//==================================================
		ImageIcon iconEmployeeManagement = new ImageIcon("images/Employee_Management.png");
		ImageIcon iconCourierManagement = new ImageIcon("images/Courier_Management.png");
		ImageIcon iconMyInfo = new ImageIcon("images/My_Info.png");
		ImageIcon iconCourierManagementManagement = new ImageIcon("images/Courier_Management_Management.png");
		ImageIcon iconCourierManagementCalculator = new ImageIcon("images/Courier_Management_Calculator.png");
		ImageIcon iconEmployeeManagementList = new ImageIcon("images/Employee_Management_List.png");
		ImageIcon iconEmployeeManagementAdd = new ImageIcon("images/Employee_Management_Add.png");
		ImageIcon iconEmployeeManagementAttendance = new ImageIcon("images/Employee_Management_Attendance.png");
		ImageIcon iconEmployeeManagementConnection = new ImageIcon("images/Employee_Management_Connection.png");
		tabbedPane.setIconAt(0,iconEmployeeManagement);
		tabbedPane.setIconAt(1,iconCourierManagement);
		tabbedPane.setIconAt(2,iconMyInfo);
		tabbedPaneCouriers.setIconAt(0, iconCourierManagementManagement);
		tabbedPaneCouriers.setIconAt(1, iconCourierManagementCalculator);
		tabbedPaneEmployees.setIconAt(0,iconEmployeeManagementList);
		tabbedPaneEmployees.setIconAt(1,iconEmployeeManagementAdd);
		tabbedPaneEmployees.setIconAt(2,iconEmployeeManagementAttendance);
		tabbedPaneEmployees.setIconAt(3,iconEmployeeManagementConnection);
	}
}
